ADR 0015doc/{zh,en}/adr/0015-app-client-protocol.md

ADR 0015: App-Client Protocol

Status: accepted, 2026-11-26 (the owner approved the scope, P0 and P1a, and the corrections of the client protocol the same day).

Status: accepted, 2026-11-26 (the owner approved the scope, P0 and P1a, and the corrections of the client protocol the same day).

Context

Orquelo's apps (the Flutter desktop, mobile and web clients of orquelo-app) and a remote orquelo tui need one protocol to the Host. plugins/httpapi v1 serves one connection's runs to a trusted proxy that names the user in the body. It has no live stream, no pairing for devices, no uploads or artifact downloads, and no view across channels. A person's task started in Feishu cannot be followed or approved in an app. The Host only offers a transport the runs of its own connection (TransportHost.Run).

Decision

  1. plugin.ClientHost, an optional TransportHost interface. Every call names the sender the transport verified, and the Host resolves it on the calling connection. A call answers only with the facts of that person: rows whose user_id is the principal's user. A person's linked accounts (ADR 0012, LinkStart/LinkFinish) therefore share their runs, questions, facts and artifacts across connections. Another person's ids answer as unknown (run.unknown, artifact.not_found, delivery.unknown), never as forbidden. The calls are Whoami, Conversations, PersonRun, CancelPersonRun, Questions, Updates, OpenPersonArtifact, Catalog, RunDiff, Deliveries and RetryDelivery. Answering uses the existing Answer, whose mayAnswer already accepts the person's linked accounts. AnswerResult gains a stable reason, so a client can tell a lost race (already_<state>, stale) from a refusal.
  2. The observed-fact log is the stream's replay source. Updates reads observed_events of the person after a seq, and the SSE id is that seq. Last-Event-ID replays exactly what the log still keeps. A cursor older than the oldest kept fact gets stream.resync_required. No new event bus or buffer is added. Progress, which has no fact, reaches open streams only, without an id.
  3. Steering stays a Trigger decision (ADR 0006). A message posted to a conversation with an active run is steered by the Trigger as on every channel, and no steer endpoint is added.
  4. Authentication stays in the transport. The static token keeps its v1 meaning: a trusted proxy names the user in the body, X-Orquelo-User or ?user=. Paired devices are added beside it: a single-use 5-minute code, a token stored only as SHA-256, rate-limited wrong codes, and revocation that also closes the device's streams. A device acts only as its user, and a request naming another is refused. A device's conversations are kept under <user>:.
  5. plugin.WorkspaceDiffer, an optional workspace-provider interface: the changes of a task checkout, committed or not. localenv implements it with git diff against the task's base.
  6. plugin.RecordProvider (amendment of 2026-11-26, the owner's choice of a public contract over calling tools). This is an optional plugin interface for records a plugin keeps about people or the deployment: RecordKinds, Records and ChangeRecord. The Host routes ClientHost.Records and ClientHost.ChangeRecord to the providers of a kind in the uses of the connection's runtime, with the caller's trusted context, and has no branch for a kind. memory serves memory, skill-workshop serves skill_draft, and the egress provider mihomo serves egress_route; each applies the rules of its own tools.
  7. Facts for the stream (same amendment). tool.started is recorded with a call's intent on every ledger path, and question.updated when a sign-in view changes. An admin's Updates also carry the question facts of approvals addressed to admins.
  8. Push through a relay (same amendment). httpapi keeps APNs/FCM registrations and posts a redacted notice (question_id, kind, title_key, platform, token) to the operator's relay. The Host has no Apple or Google client.

Consequences

  • ◆Two optional interfaces, three read queries (runs, interactions, observed facts) and a reason field. Transports that do not use them are unaffected. Process-form transports do not get ClientHost in this version.
  • ◆One behavior of v1 changes: a refused answer is now 409 (question.already_resolved, question.stale), 403 or 400 with the error envelope, where v1 answered 200 with accepted: false. Errors use one envelope (code, message_key, params, message, retryable, data).
  • ◆Facts carry a person only when their run has one. Token deltas and tool.progress are not part of this version: no runtime or tool reports them, and progress text reaches clients as message.progress.
  • ◆Management writes over HTTP (plugin enable, secrets) need both an admin caller and the operator's manage grant on the httpapi instance.
  • ◆This is the fifteenth ADR, beyond the v1 guideline of about ten. The owner approved the protocol that calls for it, and a budget of 82k lines for it, on 2026-11-26.