Deploymentdoc/{zh,en}/design/deployment.md

Release, Installation and Runtime Layout

Status: proposal (2026-11-19); S1, S2, S3a, S3b, S4, S5a, S5b and S5c built (2026-11-19, run natively on macOS only; Linux and Windows unverified), the rest not built. This documen

Status: proposal (2026-11-19); S1, S2, S3a, S3b, S4, S5a, S5b and S5c built (2026-11-19, run natively on macOS only; Linux and Windows unverified), the rest not built. This document defines Orquelo's release artifacts, the layout of an installation in ~/.orquelo, the configuration file, plugin create/read/update/delete, the multi-tenant, multi-user data layout, and starting, restarting, reloading, upgrading and graceful shutdown. The owner settled part of section 12 on 2026-11-19; the remaining questions are settled before implementation, and cases come first through vq spec per AGENTS.md section 13.

1. Background and goals

Current state (checked in code, 2026-11-19):

  • ◆The Host runs from the repository as ./bin/orquelo serve -c examples/feishu.yaml with state_dir: ../data/feishu; secrets live in ~/.config/orquelo/feishu.env, sourced by hand. There is no release artifact, installer or process supervision.
  • ◆At 11:09 on 2026-11-19 the Agent ran kill 89629 in its own shell and then tried to restart; the ORQUELO_SHELL guard (commit 0412480) refused the restart and the Feishu Host stayed down for more than five hours. The root cause is no supervisor: nothing brings a killed Host back.
  • ◆Already built: one host.lock per state directory; orquelo reload switches to a new generation through the control_requests table; on exit in-flight runs get 10 seconds before they are cancelled, and the rest is left to restart recovery; every data table carries tenant_id/user_id; the tenant comes from connections[].tenant; each plugin instance has a private DataDir (state_dir/plugins/<instance>); orquelo plugin install/uninstall/add/enable/disable/remove exist.

Goals:

  1. One command installs or upgrades: curl -fsSL …/install.sh | sh, and install.ps1 on Windows.
  2. A fixed, predictable layout: ORQUELO_HOME (default ~/.orquelo), with program, configuration, plugins, data, logs and cache kept apart.
  3. orquelo finds its configuration without -c.
  4. The Host is supervised by the system service manager (launchd / systemd --user / Windows scheduled task) and comes back after being killed or crashing; restart, upgrade and graceful shutdown each have defined semantics.
  5. File data of many tenants and users is kept in per-tenant and per-user directories whose paths the Host decides, so a plugin cannot reach another user's directory.

Non-goals (deferred until a real scenario): multiple nodes, a remote plugin market, several versions of one plugin side by side, a system-wide install (/opt, /etc, /var/lib), container images, one database per tenant, a Windows Service.

2. Prior art

TopicProjectsWhat we take
Install scriptrustup, Bun, Deno, uvcurl | sh into the user's home without root; sha256 check; add bin to PATH by default through the shell startup files or the Windows user Path; --no-modify-path opts out and prints the hint (owner, 2026-12-04, for orq; terminal UI section 6.5)
Version switchingrustup toolchains, nvm, Homebrew Cellarimmutable releases/<version>/, bin/orquelo points at the current one; upgrading switches the link
LayoutGrafana (conf/data/logs/plugins), Gitea (custom/data/log), Jenkins JENKINS_HOMEone HOME variable governs everything; configuration, data, logs and plugins never mix
Configuration lookupCodex CODEX_HOME, Claude Code CLAUDE_CONFIG_DIR, kubectl KUBECONFIGflag > environment variable > default path under HOME
Plugin managementVS Code extensions, Grafana grafana cli plugins, Helm plugins, Claude Code /pluginan installed package is distinct from an enabled instance; manifest plus pinned source and digest
SupervisionOllama, Syncthing, Tailscale, brew servicessupervised by launchd / systemd / a scheduled task; crashes are restarted; start at boot is a switch of its own
Reload and exitnginx (HUP reloads, QUIT drains), Caddy, PostgreSQL (smart/fast/immediate), Kubernetes termination gracestop admission → drain → cancel → force, each further signal escalating
Upgrade and migrationGitea, Grafana, PostgreSQLback up the database before migrating; refuse to open a newer database with an older binary
Multi-tenant dataGrafana org_id, Mattermost team_id, Nextcloud data/<user>/one database with tenant columns; files in per-tenant/per-user directories, easy to export and delete

3. Release artifacts

  • ◆GitHub Releases (jazy333/orquelo). The repository is private for now and will be open-sourced: while private, the installer fetches files through gh release download (a signed-in gh) or GITHUB_TOKEN (release asset download through the GitHub API); once public, through anonymous curl. The script supports both. Each version publishes orquelo_<version>_<os>_<arch>.tar.gz (.zip on Windows) for darwin/arm64, darwin/amd64, linux/amd64, linux/arm64 and windows/amd64, plus checksums.txt (sha256). Signatures (minisign or cosign) come with the open-source release.
  • ◆Contents: the orquelo binary; plugins/, the manifest and process plugin directories shipped with the release (such as rail-12306 and orquelo-docs); LICENSE; THIRD_PARTY.md, the notices of included third-party material; VERSION; deps/<plugin>/, what builtin plugins need beside the binary, listed with sha256 in scripts/shipped-deps.txt (the model worker and ONNX Runtime in deps/onnx, the models of local OCR and of local speech in deps/parse-ocr and deps/parse-speech; nothing on macOS amd64). Builtin plugins are compiled into the binary.
  • ◆Versions follow semver; version, commit and date are injected with -ldflags -X, and orquelo version prints them with the schema_version. plugin.HostVersion reads the injected value.
  • ◆make release cross-compiles with go build and packs the archives with a script; no goreleaser (section 9 of AGENTS.md: avoid new dependencies). The CI workflow (.github/workflows/ci.yml) builds, vets and tests natively on Linux, macOS and Windows on every push and pull request (native model APIs, section 7); it does not build or upload releases.

4. Install and upgrade

Installing and running are two separate things (decided 2026-11-19). Installing only puts a version on disk and switches to it, both the first install and every later version update; running (start, stop, restart, start at boot) is section 9. Installing never turns on start at boot; the one overlap is that an upgrade triggers the graceful restart of section 9 when the Host is running under supervision.

One command for the first install and for upgrades:

  • ◆Before anything is installed, a bootstrap script: install.sh (macOS/Linux), install.ps1 (Windows). The script only downloads and checks, then calls orquelo install --archive <file> from the archive. The install logic exists once, in Go, shared by the three platforms and testable; each script is about 60 lines.
  • ◆Once installed: orquelo install [--version V | --archive FILE]; without arguments it installs the latest version.
sh
1curl -fsSL https://github.com/jazy333/orquelo/releases/latest/download/install.sh | sh   # once open source
2gh release download -R jazy333/orquelo -p install.sh -O - | sh                          # while private
3orquelo install                                  # upgrade to the latest
4orquelo install --archive dist/orquelo_0.2.0_darwin_arm64.tar.gz   # a version just built here

Sources: a GitHub release (through gh or GITHUB_TOKEN while private), or a local archive given with --archive (the output of make release, for trying a new version on this machine, offline installs and remote deployment). Both are checked against the sha256 in checksums.txt next to them (or --sha256) and abort on a mismatch. Development builds carry the commit in their version (such as 0.1.0+dev.68abce9.<build time>), so each build gets its own version directory.

Steps of orquelo install:

  1. Check the archive.
  2. Unpack into a temporary directory, then rename it to releases/<version>/; skip when that version exists (--force replaces it).
  3. First install: create the section 5 layout; write the configuration and secrets.env (0600) with orquelo init when missing, never overwriting existing ones.
  4. Upgrade: run serve --preflight (section 9) with the new binary against the existing configuration and data; on failure stop, leaving the current version in place.
  5. Switch bin/orquelo: on Unix atomically replace the symbolic link; on Windows rename the running bin\orquelo.exe to orquelo.exe.old (Windows allows renaming a running file), copy the new one, and delete .old at the next start.
  6. When the Host runs under supervision, perform the graceful restart of section 9 and wait for the new Host to report ready (120 seconds by default). If it is not ready in time and the database was not migrated, switch back to the previous version, restart once more and report the failure; if the database was migrated, do not switch back (the old version cannot open the new database) and report the failure with the backup path for the operator.
  7. releases/ keeps at most 3 versions (the current one plus the two most recent before it), deleting older ones by install time; the running and the current version are never deleted.

Database migration happens when the new Host starts: it first backs up with VACUUM INTO to data/backups/orquelo-<old version>-<time>.db. All pending migrations then run in one transaction that takes the write lock first: a database is never left half-migrated, and processes that open a new database at once, such as serve and a CLI command, wait for each other instead of running a migration twice. A binary whose known schema_version is below the database's refuses to start and points at the backups; there is no automatic down-migration.

Code signing on macOS: the Go linker gives orquelo an ad-hoc signature whose identifier is a.out and which changes with every build; macOS therefore treats each new version as a new program, and the grants for speech recognition, accessibility, screen recording and the like must be given again after every install. A stable signature alone does not help: macOS keys the grants of a bare command-line binary by its path, and each version has its own (found on the live Host on 2026-11-30). So before step 2 renames the directory to releases/<version>/, orquelo install moves the freshly unpacked binary into an app bundle, Orquelo Host.app/Contents/MacOS/orquelo, whose Info.plist names it ai.orquelo.host and gives the reason macOS shows for each protected service a task may ask for (speech recognition, microphone, camera, control of other apps, contacts, calendars, reminders, photos, location, Bluetooth, the local network, user folders and other volumes), in English and Chinese, since macOS kills a bundled app that asks for one without its reason, signs the bundle with a code-signing certificate of the keychain under that identifier (what the desktop agent does with ai.orquelo.desktop), and leaves releases/<version>/orquelo as a link to it; bin/orquelo and the service still start that path, and the binary finds its release from inside the bundle. macOS then keys the grants by the identifier and the certificate, and later versions inherit them. ORQUELO_SIGN_IDENTITY names the certificate (by name or SHA-1 hash); when it is not set, the keychain's single code-signing certificate is used, and none or several leave the bare, ad-hoc signed binary in place, say why and let the install proceed; a setting that matches no certificate, or a failing codesign, aborts and the current version stays. The result's signed_by is the certificate used. A self-signed certificate is enough, no Developer ID: in Keychain Access, Certificate Assistant creates a self-signed certificate of type Code Signing (the desktop agent uses the one named Orquelo Desktop Dev; both can share it). A version already installed is not signed again. Other targets have no such step.

Scriptable: every install command runs unattended (--yes skips confirmations, --json prints the result, failures exit non-zero), so an operator or an Agent can deploy over ssh.

Deploying to a Linux or Windows machine (over ssh; Windows needs OpenSSH Server enabled, with commands run in PowerShell):

sh
1make release VERSION=0.2.0                       # archives for each platform plus checksums.txt in dist/
2scp dist/orquelo_0.2.0_linux_amd64.tar.gz dist/checksums.txt host:/tmp/
3ssh host 'mkdir -p /tmp/oq && tar -xzf /tmp/orquelo_0.2.0_linux_amd64.tar.gz -C /tmp/oq \
4  && /tmp/oq/orquelo install --archive /tmp/orquelo_0.2.0_linux_amd64.tar.gz --yes'
5scp secrets.env host:orquelo/config/secrets.env  # secrets are copied separately, never on a command line
6ssh host 'orquelo/bin/orquelo autostart on && orquelo/bin/orquelo start'

A later upgrade only copies the new archive and runs orquelo install --archive … remotely. There is no orquelo deploy command for now: these steps go into the documentation and the orquelo-cli skill, and a command is considered once remote deployment is used repeatedly and the steps have settled.

Uninstall: orquelo uninstall turns start at boot off, stops the Host and deletes bin/, releases/ and cache/; it keeps config/, data/, plugins/ and logs/. --purge deletes those too, after a second confirmation when interactive; scripts must spell out --purge --yes.

5. Layout

ORQUELO_HOME defaults to ~/.orquelo on macOS and Linux and to %USERPROFILE%\.orquelo on Windows (decided 2026-11-19, the same as macOS/Linux; a hidden directory since 2026-11-20, the owner's choice, was ~/orquelo).

text
~/.orquelo/
├── bin/orquelo                → ../releases/0.2.0/orquelo
├── releases/<version>/         read-only: binary, shipped plugins/ and skills/, VERSION
├── config/
│   ├── orquelo.yaml           the operator's configuration (the admin plugin writes here too, with revisions)
│   └── secrets.env            secrets as environment variables, 0600, read by the Host itself
├── skills/                    system-level skills; third-party ones in skills/third-party/ ([install levels](/en/docs/install-levels))
├── plugins/                   system-level plugins (first of plugin_dirs); third-party ones in plugins/third-party/
├── data/                      state_dir: all state of one Host
│   ├── orquelo.db             SQLite (WAL) with tenant_id/user_id columns
│   ├── secret.key             encryption key, 0600
│   ├── host.lock              single-Host lock
│   ├── host.json              pid, version, start time, supervisor, status (written while running)
│   ├── instances.json         snapshot of instance status
│   ├── backups/               pre-migration and manual backups
│   ├── host/<instance>/       Host-scoped instance data (such as a channel token cache)
│   └── tenants/<tenant>/
│       ├── shared/                    tenant data that belongs to no single user
│       │   ├── instances/<instance>/  shared instance data (such as a team knowledge index)
│       │   ├── skills/<name>/         tenant-level skills
│       │   ├── plugins/<name>/        tenant-level plugins
│       │   ├── artifacts/<id>         artifacts without an owning user (such as system notices)
│       │   └── workspaces/<conv>/     a group chat's conversation workspace
│       └── users/<user>/
│           ├── instances/<instance>/  the user's private instance data (such as Memory, skill drafts)
│           ├── skills/<name>/         user-level skills, seen only by the user's runs
│           ├── plugins/<name>/        user-level plugins
│           ├── artifacts/<id>         artifacts made by the user's runs
│           └── workspaces/            the user's workspaces and worktrees
├── logs/                      orquelo.jsonl (rotated by size), service.log (the supervisor's stdout/stderr)
├── deps/<plugin>/             plugin prerequisites (npm/uv packages and the like, `${PLUGIN_DEPS}`; rebuilt by `plugin doctor`)
├── cache/                     downloads and install staging
└── tmp/                       temporary files, cleaned at start

Rules:

  • ◆releases/ is read-only and an upgrade never changes an old version. Shipped plugins load from releases/<current>/plugins, after plugins/, so a user-installed plugin of the same name wins (the same ordering as plugin_dirs today).
  • ◆No state is written outside data/; cache/ and tmp/ may be deleted at any time.
  • ◆Tenants and users appear in paths only by opaque Host-generated IDs (default, us_…), never names or open_ids.
  • ◆One HOME runs one Host. Tests or a second bot use another HOME: ORQUELO_HOME=~/.orquelo-test orquelo serve.

6. Configuration

Lookup order: -c FILE > $ORQUELO_CONFIG > $ORQUELO_HOME/config/orquelo.yaml. Every command follows it, so -c becomes optional. The development setup (-c examples/feishu.yaml, relative paths resolved against the file's directory) keeps working.

A new variable, ${ORQUELO_HOME}, is always available to ${ENV} expansion. Defaults written by orquelo init:

yaml
1state_dir: ${ORQUELO_HOME}/data
2env_file: ${ORQUELO_HOME}/config/secrets.env   # new: read by the Host at start and reload
3plugin_dirs: [${ORQUELO_HOME}/plugins]          # the shipped plugin directory is always appended last
4log: {dir: ${ORQUELO_HOME}/logs}
5locale: zh-CN
6shutdown_grace: 30s                              # new, see section 9
7restart_slow_after: 2m                           # a longer /restart is reported as unusually long; 0 off
8watch_config: true                               # new: reload automatically after the file is saved
9environment: {}                                  # new: non-sensitive process environment (PATH, proxies), see section 11
10tenants:                                         # new, see section 8
11  - {id: default, name: Default}
12plugins: []
13connections: []
  • ◆The Host reads env_file itself, without a shell source, systemd EnvironmentFile or launchd environment, so a manual start and a service start behave the same. Its variables feed only ${…} expansion and never enter the process environment, so shell tools do not see them (in line with the decision to withhold Host secrets from the shell). A variable already in the process environment wins.
  • ◆Sensitive options are still best kept with orquelo secret set (encrypted in the database); secrets.env holds start-up credentials such as channel and model keys.
  • ◆Automatic reload (watch_config, on by default): the configuration file and env_file are watched; 1 second after the last change the file is validated. If it passes, a new generation takes over (as with orquelo reload); if not, config.reload_rejected is logged, the current configuration keeps serving and admin conversations get a notice. A half-saved file fails validation and has no effect. Upgrading the binary (including the builtin plugins compiled into it) still needs a restart.
  • ◆The configuration stays one file. orquelo config validate checks without starting; orquelo config edit opens $EDITOR, then validates and reloads on save. Revisions and rollback stay as config history|rollback.
  • ◆No conf.d/ merging: the admin plugin writes back to the single file, and several files would make the target of a write ambiguous.

7. Plugin create, read, update, delete

Plugins have two layers, and commands are split by layer (two command groups, decided 2026-11-19): the package (a plugin directory on disk, by name) and the instance (an entry in the configuration, by ID).

OperationPackage (orquelo plugin …)Instance (orquelo instance …)
Createinstall SOURCE (built)add ID PLUGIN [-uses] [-option] (built, formerly plugin add)
Readlist, show NAME (new: source, version, digest, roles, which instances use it), search (built)list, show ID (new: status, roles, uses, scope, effective configuration with sensitive values masked)
Updateinstall -upgrade (built), check, doctor, approveset ID KEY=VALUE…, unset ID KEY (new: edit the instance config, validated against config_schema), enable/disable (built)
Deleteuninstall NAME (built; refused while an instance uses it)remove ID [-force] (built; refused while referenced)
  • ◆Every change goes through the existing manage.Manager: atomic write-back, a revision, and a reload request to a running Host. Without a running Host only the file changes.
  • ◆plugin add|enable|disable|remove stay as aliases of instance … for one version, with a deprecation note.
  • ◆Removing an instance does not delete its data at once: the data moves to data/trash/<instance>-<time>/ and is purged when retention expires; remove -purge deletes it now. An instance removed by mistake can get its data back.
  • ◆Permission tiers follow the orquelo-cli skill: read commands are open to any operator; changing commands from the Agent's shell go through the Host's manage grant and approval (the existing grants: [manage]).

Third-party plugins and outside paths:

  • ◆Install levels: skills and plugins install at the system, tenant, user or workspace level (the workspace's .orquelo/skills and .orquelo/plugins), chosen at install time; locations, approvals, visibility, names and implicit instances are in install levels for skills and plugins. Source, commit and digest are recorded in the database, and changed files need a new approve (built); third parties get no extra permissions and no fewer checks. Options that differ per user keep using per-principal secrets (Caller.GetSecret, built).
  • ◆Prerequisites: npm/uv and similar dependencies a plugin declares go into ~/.orquelo/deps/<plugin>/ (today state_dir/deps/<plugin>), not cache/, because deleting them makes the plugin unusable; orquelo plugin doctor rebuilds them when lost. System packages (apt, brew and the like) still install only after confirmation.
  • ◆Code downloaded at run time: MCP servers started with npx or uvx download code on first run into npm's or uv's own cache. The Host points npm_config_cache, UV_CACHE_DIR and the like at ~/.orquelo/cache/<plugin>/ for plugin processes, so downloads stay inside HOME and can be cleaned; versions should be pinned in the manifest (such as 12306-mcp@1.2.3), otherwise each start may fetch different code, and the documentation flags that as a risk.
  • ◆Referencing outside directories: skilldir paths (such as ~/.agents/skills, ~/.claude/skills) and plugin_dirs entries outside HOME are only referenced, never copied, so they are outside backups, home import and remote deployment, and their changes do not go through approve. Configuration validation notes paths outside HOME; when they must move with the Host or be subject to approval, orquelo plugin install DIR copies them in.
  • ◆Writing paths: configuration paths may use ~, ${ORQUELO_HOME} and environment variables, resolved per platform; documentation examples never hardcode POSIX paths.

8. Multi-tenant, multi-user data

Tenant model. Several tenants are supported this round (decided 2026-11-19, one node). Tenants become a top-level configuration item:

yaml
1tenants:
2  - id: acme
3    name: Acme Inc.
4    locale: zh-CN
5    admins: [{connection: feishu-acme, user: ou_xxx}]   # tenant admins
6    limits: {tokens_per_user_per_day: 2000000}
7connections:
8  - {id: feishu-acme, tenant: acme, transport: feishu-acme, …}
  • ◆A tenant is bound only through a connection and never inferred from a message, plugin or model payload (AGENTS.md section 7). The existing connections[].tenant field is unchanged; an ID referenced but not listed in tenants fails validation, and without tenants there is only default.
  • ◆Four roles: the operator (the OS user owning HOME, using the CLI), Host admins (the top-level admins, meaning what they mean today: from a conversation they may stop, restart and upgrade the Host and manage plugins, affecting every tenant), tenant admins (tenants[].admins, managing only their tenant's users, sessions and approvals, never restarting the Host), and users.
  • ◆Plugin instances belong to the whole Host by default; the existing scope limits them to some connections and so to some tenants. Instances are not copied per tenant.

Database. Still one SQLite database whose data tables carry tenant_id and user_id (built). One database per tenant waits for multiple nodes.

File data. Three Host-computed directories replace today's single DataDir:

ScopePathWho gets it
Hostdata/host/<instance>/the instance itself (plugin.Context.DataDir, meaning unchanged)
Tenantdata/tenants/<t>/shared/instances/<instance>/only when the call's trusted context belongs to tenant t
Userdata/tenants/<t>/users/<u>/instances/<instance>/only when the call acts for user u
  • ◆Plugins get tenant and user directories through plugin.Env.TenantDir(tenant) and Env.UserDir(principal) (ADR 0010), filled only from the principal the Host gave them, never from an id they choose. The designed Caller.Dir became path patterns on Env, since observers and similar calls have no Caller. An instance that already has plugins/<instance>/ keeps using it (plugins keep absolute paths in it, such as git worktrees); new instances use host/<instance>/. (Built, S5a: tenants configuration, tenant admins, artifacts per user, Memory's user and conversation directories, moving and deleting files when users merge or are forgotten.)
  • ◆Artifacts are stored per user: in tenants/<t>/users/<u>/artifacts/, where <u> is the user of the run that made it (artifacts.user_id in the database, already written from the run). An artifact made in a group chat also belongs to the user who started the run; who may read it is decided by the database record and grants, not by the path. Artifacts without an owning user go to tenants/<t>/shared/artifacts/. Deleting or exporting a user then handles their artifacts with the directory.
  • ◆A conversation's scratch workspace lives with its owner: a direct chat's under the person's directory (tenants/<t>/users/<u>/instances/<localenv>/conversation/…), a group's under the tenant's (shared/instances/<localenv>/conversation/…); one kept in the old place moves there with its files on first use, and scratch_expiry and scratch_quota_mb still apply. A configured root or dir, per: shared/principal, named workspaces and git worktrees are not moved (a worktree's absolute path is recorded in its repository). (Built, S5c.)
  • ◆Merging users (identity link): the Host moves the merged user's directories into the kept user's, renaming and keeping conflicting files, recorded in the same operation as the database rows so it can be redone after an interruption.
  • ◆Deleting a user (sessions forget, later user delete) deletes that user's directories; export (orquelo tenant export T) packs tenants/T/ with the tenant's database rows; deleting a tenant needs a second confirmation from the operator.
  • ◆The honest boundary: every tenant runs under one OS user, and the isolation is logical. Shell and file tools are not a sandbox: a user with full localenv access can read the whole HOME. Serving untrusted tenants requires restricted tools for them (safe-shell, a sandbox plugin), and the documentation says so.

Skills and plugins users develop. Drafts of skills and plugins users develop in conversations go to the author's directory automatically (the workshop uses Caller.Dir(user), i.e. users/<u>/instances/<workshop>/drafts/); publishing chooses a level, the user level by default. Locations, approvals and visibility per level are in install levels for skills and plugins.

9. Supervision and lifecycle

Goals (decided 2026-11-19): start at boot; come back after a crash or a kill; let Host admins restart gracefully from Feishu or the console (and the TUI later), and a restart must never leave the Host down.

Run commands: orquelo start|stop|restart|status and orquelo autostart on [--at-login]|off. start first registers the service definition when it is missing (so the Host always runs supervised and a crash is restarted), then starts it through the service manager; autostart only decides whether it starts by itself at boot or login. orquelo serve stays as the foreground form (development, debugging), and a Host started that way is not supervised.

How start at boot works: autostart on starts at boot by default; --at-login starts after the user logs in instead:

SystemAt boot (default)At login (--at-login)
macOS/Library/LaunchDaemons/ai.orquelo.host.plist with UserName set to the current user; installed once with sudo~/Library/LaunchAgents/ai.orquelo.host.plist, no sudo
Linux~/.config/systemd/user/orquelo.service plus loginctl enable-linger (starts at boot without a login)the same unit without linger
Windowsa scheduled task triggered at system start, running as the current user with S4U (no stored password; local resources and network only)a scheduled task triggered at the user's logon
  • ◆Both run <HOME>/bin/orquelo serve as the current user and restart it on a non-zero exit: launchd KeepAlive: {SuccessfulExit: false}; systemd Restart=on-failure, RestartSec=3, StartLimitIntervalSec=0 (never giving up after repeated failures); the Windows task's command restarts orquelo itself 3 seconds after a non-zero exit and ends after exit 0, so the rule does not depend on how Task Scheduler counts failures. TimeoutStopSec (launchd's ExitTimeOut) is shutdown_grace plus 15 seconds. The service name derives from the installation directory (ai.orquelo.host.<hash>), so two installations on one machine never clash. orquelo stop and orquelo restart do not go through the service manager: they write a control request the Host carries out itself, so they need no administrator rights on any platform; the macOS at-boot form is a LaunchDaemon, whose installation and start need sudo once, and the command prints what to run. (Built, S3a.)
  • ◆The service sets ORQUELO_SUPERVISOR=launchd|systemd|schtasks; the Host records it in host.json and uses it to decide whether it can restart.
  • ◆orquelo status shows, beside today's run and delivery counts, the version, pid, start time, whether it is supervised, whether it starts at boot, and the last exit reason from host.json; while the Host runs, each connection that reported its health, up or down since when and why (ADR 0019).

Signals and commands:

ActionCommandUnix signalMeaning
Reload configurationorquelo reload, saving the configuration file (watch_config)SIGHUPhot reload: a new generation takes over, in-flight runs stay on the old one (built; SIGHUP changes from "exit" to "reload")
Graceful stoporquelo stopSIGTERM, SIGINTphases 1–5 below, exit code 0, the supervisor does not start it again
Fast stopa second signalsameskip draining and cancel in-flight runs at once
Immediate exita third signalsamedo not wait for plugins; what remains is left to restart recovery
Restartorquelo restart, /restart in a conversation—see "Graceful restart"; exit code 75 for the supervisor to start it again

Graceful restart. The CLI, Feishu and the console share one path: each only writes a control_requests(kind=restart) row, and the Host carries it out:

  1. Authorization: /restart in a conversation is accepted only from Host admins (the top-level admins, through any linked account); tenant admins and users are told they may not (stable error code restart.forbidden). The CLI counts as the operator. orquelo restart from the Agent's shell is refused (section 10).
  2. Preflight (no restart unless it passes): unsupervised (running in the foreground as orquelo serve) → refused, pointing at running it with orquelo start. The binary about to start (the new version during an upgrade) runs orquelo serve --preflight: load and validate the configuration, read env_file, open the database read-only and check that its schema_version is compatible, check that the plugins load and, by serve's own check, that each connection's instances play their roles (a runtime that is a trigger fails here, not at the start). Any failure refuses the restart with the concrete reason, and the Host keeps serving.
  3. Notice: the requester is told "restarting: N runs will continue from their checkpoints, M will end" (localized message key host.restarting), and the requester's conversation is recorded.
  4. Stop: the graceful stop of phases 1–5 below, exit code 75.
  5. Report: once the new Host has started and finished recovery, it tells the requester's conversation "restarted: version, downtime" (host.restarted, sent once). When the downtime exceeds restart_slow_after (default 2m, 0 off; a value without a unit or a negative one is refused), it says instead that the restart took unusually long and what most of the time went to: waiting for runs, for the plugins to stop, or starting again (host.restarted_slow). The stopping Host stamps the notice when the drain ends and when the plugins are stopped. (Built.)

While the Host is stopped nothing in a conversation can receive /restart; only the start at boot, the crash restart or the operator's CLI (orquelo start, over ssh too) can start it. The documentation and the help of /restart say so.

Phases of a graceful stop (each logged as host.shutdown_phase):

  1. Stop admission: the Host admits no new events: a transport's submit gets the retryable host.stopping (retry_after_ms 30000), httpapi answers 503 with Retry-After, and Feishu, given the error, redelivers later (deduplicated by message_id; the platform's redelivery is not verified live). Transports keep running through the drain and stop after it, so answers to approvals and deliveries go on. Events already in the inbox stay and are handled after the restart. (Built, S3a.)
  2. Drain runs: wait up to shutdown_grace (default 30s, replacing the fixed 10s) for in-flight runs. Runs waiting for an answer are parked at once (built). Runs of runtimes that declare resumable are paused at once (built): their next Commit stores the step and returns run.paused, the runtime returns it, and the run is left running with that checkpoint for restart recovery, so a step is never cut short and the drain does not wait for the whole run. A pause that lands on the final step finishes the run. A run that reaches no step boundary within the grace is cancelled like the others.
  3. Flush deliveries: queued deliveries (including the notice of step 3 above) keep sending within the remaining grace; what is unsent is continued by the Worker after the restart, never by rerunning the runtime.
  4. Stop plugins: first services and MCP servers, then process plugins: shutdown (2 seconds), then stdin closed, SIGTERM after 5 seconds and a kill after 5 more; on Windows, which has no SIGTERM, the kill comes 5 seconds after stdin closes. Each step is logged as plugin.stop_step (built).
  5. Finish: checkpoint the database WAL and close it, release host.lock, mark host.json stopped with the exit reason, and exit.

Runs still going when the grace ends are handled by the existing restart recovery: resumable runtimes continue from their checkpoint, other runs fail and the user is told; tool calls left started in the ledger are reported as unknown and never resent.

10. Fixing "the Agent killed its own Host"

Three independent layers:

  1. Supervision as the backstop (the real fix): with section 9, however the Host is killed it is back within seconds and runs restart recovery.
  2. A proper path for the Agent: orquelo restart in the Agent's shell stays refused and says to ask an admin to send /restart in the chat (section 9); the orquelo-cli skill says "to restart, ask an admin for /restart, never kill". The designed "restart from the shell after an admin's approval" is dropped by the owner's decision (2026-11-19, section 12): the shell does not know its run or conversation, and an approval outside the runtime needs a new interaction mechanism, while an admin's /restart already covers restarting from a conversation (2026-11-19). (Built, S3b.)
  3. Refusing self-kill commands: localenv sets ORQUELO_SHELL=1 and ORQUELO_HOST_PID in the shell; the bash/powershell tool (including ! commands in a conversation, decided 2026-11-19) refuses before running a kill/pkill/killall/taskkill/Stop-Process command naming the Host's pid, $ORQUELO_HOST_PID, orquelo serve or orquelo.exe, or killing orquelo by name, with the hint of layer 2. This is best effort and does not catch every spelling; layer 1 is the guarantee. (Built, S3b.)

11. The development setup is a deployment too

The Feishu bot on this machine and any other long-running Host are ordinary installations, no different from a remote machine (decided 2026-11-19); only the first time is the existing configuration and data migrated. orquelo serve -c examples/….yaml in the repository is kept for development, debugging and veruqelo case runs, and no longer carries the live bot.

The everyday development loop:

sh
make install-local        # build this platform's archive (version such as 0.1.0+dev.68abce9.<build time>), then orquelo install --archive

orquelo install runs the preflight, switches versions and restarts gracefully (sections 4 and 9); no more manual kill, nohup and source. What this gains:

  • ◆The live bot is isolated from the working tree: shipped plugins load from releases/<version>/plugins/, a snapshot taken at build time; uncommitted changes in the working tree do not affect the live bot, nor make a plugin unavailable with changed_since_approved at the next start.
  • ◆Plugin approval moves to install time: orquelo install lists shipped plugins whose digest differs from the approved record; the operator confirms (--yes counts as confirming) before the version switches. The installer does not write a running Host's database: the approvals go to data/approvals.pending.json, which the new Host records at start, before loading plugins. Until it restarts, the running Host keeps the shipped plugins and shipped dependencies (deps/<plugin>/) of the release it started from, through every reload, so a switch never leaves it reading plugin files it has not approved.
  • ◆Concurrent installs are serialized: several Agent sessions may deploy at once. orquelo install holds ~/.orquelo/install.lock; a later one waits or reports "another install is in progress"; every install and restart appears in the recent history of orquelo status (version, requester, time).

Process environment: a Host started by the service manager does not inherit the login shell's environment, so proxies (such as 127.0.0.1:17897) and PATH (node, go, gofmt and the like) go missing. The configuration gains environment:, listing non-sensitive process environment variables that the Host sets on itself, on the plugin processes it starts and on the commands of the shell tool, at start and again on every reload (a variable no longer listed gets back its earlier value; commands already running keep theirs; configuration section 6):

yaml
1environment:
2  PATH: /opt/homebrew/bin:/usr/local/go/bin:/usr/bin:/bin
3  HTTPS_PROXY: http://127.0.0.1:17897
4  NO_PROXY: localhost,127.0.0.1

orquelo init and home import read PATH and the proxy variables from the current shell and write them after asking. Secrets still go only into secrets.env or the secret store, never into environment.

First migration: orquelo home import --from data/feishu --config examples/feishu.yaml [--env ~/.config/orquelo/feishu.env]: (Built, S5b. Where it differs from the steps below: plugin_dirs entries inside the state directory (such as installed/) are copied to ~/.orquelo/plugins, other entries stay as absolute paths instead of being dropped; backups/ is not copied; --home DIR names the installation.)

  1. Requires the source Host to be stopped (takes its host.lock).
  2. Copies the configuration to config/orquelo.yaml: relative paths become ${ORQUELO_HOME}/…; plugin_dirs entries pointing at the repository's plugins/ are dropped (those plugins now come from the shipped directory); plugins in data/feishu/installed/ (such as learned-skills) move into the store ~/.orquelo/plugins/; environment is filled in.
  3. After asking, copies the env file to config/secrets.env (0600).
  4. Copies the database with VACUUM INTO and copies secret.key and the plugin approvals; moves plugins/<instance>/, artifacts/ and workspaces into the section 8 layout (instance data whose owner cannot be determined goes to host/<instance>/); rewrites workspace and artifact paths stored as absolute paths in the database.
  5. Leaves the source directory untouched, so going back is possible; finishes by suggesting orquelo start and orquelo autostart on. After the migration the old nohup start is no longer used.

12. Decisions (2026-11-19)

  1. HOME on Windows is %USERPROFILE%\.orquelo.
  2. The repository is private for now and will be open-sourced; the installer supports both gh/GITHUB_TOKEN and anonymous download (sections 3 and 4).
  3. Several tenants are supported this round (section 8); requirement D01 is updated to match.
  4. SIGHUP becomes a configuration reload; watch_config is on by default, so saving the configuration file hot-reloads it (section 6).
  5. The system service manager supervises the Host and starts it at boot by default; in a conversation only Host admins may /restart; a restart runs a preflight first, does not happen if it fails, and reports when done (section 9).
  6. Packages and instances get two command groups, orquelo plugin … and orquelo instance … (section 7).
  7. Installing and running are separate: orquelo install handles the first install and version updates (also for trying a new build here and for deploying to Linux/Windows over ssh), and orquelo start|stop|restart|status|autostart handle running (sections 4 and 9).
  8. The development setup is an installation too: home import migrates the existing configuration and data once, and make install-local deploys afterwards (section 11).
  9. Personal skills take effect as soon as the author publishes, without approval; plugin code needs a Host admin's approval at every level (section 8).
  10. Code comes first; native Linux and Windows environments are provided later, and until then those platforms are reported as unverified.
  11. Skills and plugins can be installed and used at all four levels, system, tenant, user and workspace; given an address, a bare skill installs directly with the level chosen (install levels).
  12. No "orquelo restart from the shell after an admin's approval": the bot's shell refuses restart, stop and start, and asks an admin to send /restart in the chat (section 10).

13. Slices and acceptance

Each slice is its own commit, with cases from vq spec first, including one e2e case through a real channel. Estimated production code: about 2.5k lines.

SliceContentAcceptance
S1ORQUELO_HOME, configuration lookup, ${ORQUELO_HOME}, env_file, new init defaultsevery command works without -c; variables from secrets.env never appear in a shell tool's environment
S2injected version, make release, make install-local, the install lock, approving shipped plugins at install time, install.sh/install.ps1, orquelo install|uninstall, deployment documentationnatively on three systems: fresh install, repeated install, --archive install of a local build, abort on a bad checksum, no switch after a failed preflight, upgrade switch, replacing the running exe on Windows, backup before migration, older binary refuses a newer database; deploying over ssh to one Linux and one Windows machine
S3start|stop|restart|status, autostart on|off (at boot/at login), restart and /restart, preflight, SIGHUP and watch_config hot reload, shutdown_grace and the five-phase stop, section 10natively on three systems: the Host runs after a machine reboot; it recovers after kill -9; an admin's /restart in Feishu gets "restarting" and "restarted", a non-admin is refused; a failed preflight (a bad configuration) does not restart and the Host keeps serving; in-flight runs finish within the grace or resume from a checkpoint; deliveries never rerun the runtime; saving a bad configuration has no effect
S4plugin list/show, instance list/show/set/unset, instance data to trashafter a change the revision count grows and the Host has reloaded; a set violating the schema is refused
S5ADR 0010 Caller.Dir, per-tenant/per-user directories, moving files when users merge or are deleted, home importtwo users cannot reach each other's directories; a merge redone after an interruption gives the same result; Feishu e2e passes after importing data/feishu
S6Install levels: skill install, --to, the four-level skill source, implicit instances, workspace trustsection 9 of that document

Section 8 of the architecture has the budget row "release, installation and lifecycle" (approved by the owner on 2026-11-19, raising the total, with goal mode, to 55k).