ADR-0001: One process runs the web app and the durable pipeline
- Status: accepted
- Date: 2026-11-12
- Decided by: Stefan Imhoff
Context
Hotaru has a web app (UI, REST API, live updates, auth) and long-running work: the polling scheduler, the item pipeline and the chat agent. The long-running work is built on pi-durable.
The SI-512 spike showed that pi-durable allows one writer per storage. It has no cross-process locking, so exactly one process may open the harness database for writing. Other processes may only read it. The chat (M3) has to submit to that harness and watch it live from the browser.
Konbini, my other SvelteKit + Drizzle app, runs as one process and one container. Its live updates work because the change counters are in memory (docs/live.md there). Hotaru runs on a single Hetzner VPS for one user to begin with.
Decision
The SvelteKit server (apps/web, adapter-node) is the only process. Its server init hook starts the core runtime from packages/core: the pi-durable harness, the scheduler and the item pipeline. UI routes, the REST API and the SSE endpoints call core in the same process. Hotaru runs as exactly one replica.
packages/core must not import SvelteKit. That keeps a later move to a separate worker possible, if one is ever needed.
Rejected alternatives
- Web app plus a separate worker process. The worker would own the harness, the scheduler and the pipeline, and the web app would talk to it over internal HTTP. It isolates pipeline load from request handling. But it needs an internal API for chat submissions, a second event channel to get worker changes into the browser’s live stream, and two services to deploy and monitor. Its benefit doesn’t apply at this size: the pipeline spends its time waiting on network calls (feeds, OpenRouter, jev), not on the CPU.
- A separate API server with a separate frontend, like the reference repo (
dna-server-apiplus a browser app behind a token hub). That layering exists there because the browser client is a standalone app. SvelteKit already serves the UI and the API from one server, which is what Konbini does. - A system cron that calls the API, as in the reference repo. Adaptive polling needs a next-check time per source (SI-522), and pi-durable tasks already persist and resume. An in-process scheduler reads the due sources directly. A cron job would only be one more moving part.
Consequences
- Live updates and chat streaming are simple: in-memory change versions and pi-durable watches feed SSE directly.
- A deploy or crash stops the pipeline for a moment. pi-durable resumes from the last checkpoint on start, and no finished work is repeated (shown in SI-512).
- A slow, CPU-heavy step would delay web requests. If one appears (a large OPML import, say), it gets chunked or moved to a worker thread first, before the process is split.
- No horizontal scaling. For more capacity, the VPS grows. Splitting out a worker means writing a new ADR that supersedes this one.
- In development, Vite reloads modules. The harness must be a
globalThissingleton so a reload doesn’t open a second writer (see conventions.md).
Notes
- 2026-11-12: The scheduler runs in this process as planned, but its fetches aren’t durable tasks. They’re a plain loop, because a fetch can safely run twice (ADR-0004). The “pi-durable tasks already persist and resume” argument above applies to the item pipeline (SI-533).