whiskers.git / backend / worker / README.md
1# worker
2
3Whiskers' hubs as a Cloudflare Worker with one Durable Object per household. The same build (`worker-build --release`,
4giving `build/index.js` and `build/index_bg.wasm`) runs under Cloudflare's `wrangler dev` and under `celld dev`.
5
6What it serves today: `POST /memory/sync`, `/household/sync` and `/chat/sync`, answered by `whiskers-service` over a backend
7whose three hubs live in the household's object. That is all the Worker has (it implements `HasMemory`, `HasHousehold` and
8`HasChat` and no other capability), so it is all the service is given: every other route, `/check` and `/usage` and
9the rest, is not there and answers 404 as an unknown path does. Moving a capability onto the Worker is implementing its
10`Has…` trait and giving the service its route (`Service::serve`), see `crates/whiskers-ports/README.md`.
11
12| Path | What |
13| --- | --- |
14| [src/](src/) | The adapter. |
15| [tools/](tools/) | `host` starts, stops and restarts native, wrangler and celld each on its own port; `crosscheck` runs the whole comparison; `probe` shows what each host says to a few odd requests. |
16| `wrangler.jsonc` | The one configuration both hosts read. Only keys celld accepts: no `routes`, never `.toml`. |
17| `.dev.vars` | Read by `wrangler dev` and `celld dev` only. It switches on the test mode (see `src/household.rs`). |
18
19Run it:
20
21```
22mise run backend:build           # worker-build --release: build/index.js and index_bg.wasm
23mise run backend:celld           # self-hosted, no bucket; state in .celld/dev
24mise run backend:wrangler        # wrangler dev --local --persist-to .wrangler/state
25mise run test:backend            # the pure parts, natively
26```
27
28One deployment serves **one household**, named by the `HOUSEHOLD` setting: the wire carries no credential today, so
29nothing could say which household a request is for. A harness that needs a fresh household per test turns on the
30test mode in `.dev.vars` (`TRUST_HOUSEHOLD_HEADER=1`), which neither `deploy` reads.