whiskers.git / backend / worker / CLAUDE.md

For agents, on top of README.md, which they read first.

Notes for agents

  • No merge rule here. src/documents.rs calls MemoryDoc::merge, Household::merge and ChatState::merge of whiskers-core. A rule that needs to change changes there.
  • Do not put an await between a document's read and its write (documents::merge_in, object.rs). That is what makes a merge atomic on both hosts: celld lets an event that awaits overlap another.
  • Config is the shared subset: wrangler.jsonc, no routes, binding names distinct from vars names (both hosts refuse a clash), main: ./build/index.js with no_bundle (build/worker/shim.mjs re-exports ../index.js, which a prebuilt Worker cannot import on either host). A Cloudflare route belongs to the deployment overlay, not this file.
  • Never log content. Nothing here writes a document, a fact or a body to the log: counts, statuses, kinds. A parse error's own text quotes the input; log classify() instead.
  • The /_hub/... routes exist only in the test mode (Households::is_testing); keep it that way, so a deployment cannot serve them.
  • There are no stand-ins. ObjectBackend implements a capability (HasMemory...) only for a port the Worker really has, and lib.rs gives the service only the routes for those. Never add a port that answers "not here" to satisfy a bound: if a route's bound is not met the route is not served, and the compiler is what says so. Moving a capability onto the Worker means a real implementation, its Has… impl, the .serve(...) of its routes, and its fixture in the conformance harness (documents.rs tests).
  • The log level is WHISKERS_LOG, as everywhere in Whiskers.