Core Designdoc/zh/design/architecture.md
Host & Plugin Architecture
The five-stage pipeline, single-owner SQLite state, and the reliability rule that every state has an exit.
Five-Stage Pipeline
A connection wires one plugin instance per stage. A single plugin can play multiple roles at once—for example, the Feishu plugin acts as Transport, Presentation, and Delivery while sharing one persistent connection.
Orquelo Host coordination loop
Feishu / HTTP API / TUI / Schedule / Webhook
│
▼
Transport ──▶ Inbox (dedup) ──▶ Trigger ──▶ Run ──▶ Runtime (agent / @claude / @codex)
│ │ ▲ host.call (uses / scope / approvals)
Worker Loop ▼ │
Interaction (CAS approvals) Presentation ──▶ Delivery Outbox ──▶ Targets
└──── SQLite: events, runs, tool ledger, deliveries, artifacts ────┘| Stage | Responsibility | Guarantee |
|---|---|---|
| Transport | Ingests channel events into inbox (~100ms ack) | Idempotent dedup by message_id / event_id |
| Trigger | Decides ignore, start, cancel, answer, or reply | Handles /, @runtime, $skill, ! shell, and steering |
| Runtime | Executes a Run (Go Agent or external CLI/ACP) | Resumable checkpoints; always notifies on exit |
| Presentation | Renders channel-agnostic Output into Items | Shared pkg/designlang states and block order |
| Delivery | Delivers each item with backoff retry | Committed atomically with Run; never reruns runtime |
Reliability: Every State Has an Exit
- ◆Single Worker loop: every run, delivery, question timeout, and retention sweep has a deadline.
- ◆Intent-first tool ledger: failures distinguish definitely-not-sent (retryable) from possibly-sent (unknown), preventing duplicate side effects after crashes.
- ◆Persistent CAS interactions: approvals, questions, and sign-in flows carry QuestionView.Version and settle atomically from any linked channel.
- ◆Pinned tool catalog & prefix stability: tool schemas are pinned per run, while fixed core tools + tool_search maximize prompt cache reuse.
Hard Boundaries
Zero Host Special Cases
Plugins never import each other or internal/, and never read another plugin's data directory. Identity and grants come solely from Host CallContext.