Overview

Message flow

Channel adapter
  โ†’ POST /v1/messages (api)
  โ†’ store.PutMessage                     all messages (inbound/outbound/delegation)
  โ†’ gateway.messageLoop (polls every 2s)
  โ†’ store.NewMessages (unprocessed since lastTimestamp)
  โ†’ impulseGate.accept(jid, msgs)       weight-based batching (100 threshold)
  โ†’ Three-layer pipeline:
      1. Sticky layer                    absorbs bare @name/#topic tokens
      2. Command layer                   matches slash-prefixed tokens (/new, /ping)
      3. Prefix layer                    inspects @name/#name inline, navigates to child/topic
      4. Routing layer                   walks routes table (seq order, match expressions)
  โ†’ queue.EnqueueMessageCheck
  โ†’ processGroupMessages
      โ†’ store.MessagesSince              per-chat agent cursor
      โ†’ store.FlushSysMsgs              XML system events prepended
      โ†’ router.FormatMessages            XML message batch
      โ†’ grants.DeriveRules               inject into start.json
      โ†’ container.Run                    docker run -i --rm
      โ†’ stream output
      โ†’ router.FormatOutbound            strip <internal> and <think> tags
      โ†’ store.PutMessage                 outbound messages return to unified path
  โ†’ POST /send to channel adapter

Daemons

NameLanguageRole
gatedGoMessage loop, routing, container dispatch
timedGoCron poll, inserts scheduled messages
onbodGoOnboarding state machine (optional)
dashdGoOperator dashboard (HTMX, read-only)
proxydGoAuth perimeter; /pub/ is public, everything else JWT-gated; /dash/, /auth/, Vite proxy
teledGoTelegram Bot API adapter (long poll)
discdGoDiscord Gateway adapter (websocket)
mastdGoMastodon streaming adapter
bskydGoBluesky firehose adapter
reditdGoReddit polling adapter
emaidGoEmail adapter (IMAP/SMTP)
whapdTypeScriptWhatsApp adapter (Baileys multidevice)

SQLite tables

TablePurpose
messagesAll inbound and outbound messages; primary poll target for the gateway
chatsKnown JIDs with name, channel, and error flag
routesRouting rules: seq, match expression (key=glob pairs), target group
registered_groupsActive groups with folder, trigger word, container config, parent, slink token
sessionsCurrent Claude Code session ID per (group_folder, topic)
session_logHistorical session records with start/end time and result
system_messagesXML system events prepended to agent prompts
scheduled_tasksCron and one-shot tasks with status and next_run
router_stateKey/value persistence for lastTimestamp, lastAgentTimestamp
auth_usersWeb auth accounts (argon2 hashed passwords)
auth_sessionsJWT refresh token hashes with expiry
user_groupsMaps web users to specific group folders
email_threadsMaps email thread IDs to chat JIDs
onboardingPer-JID onboarding state machine records

Repository layout

cmd/arizuko/        CLI entrypoint (generate, run, create, group, status)
core/               Config, types, Channel interface
store/              SQLite persistence
api/                HTTP API server (channel protocol endpoints)
auth/               Identity, authorization, JWT, OAuth, middleware
chanreg/            Channel registry, health checks, HTTP channel proxy
gateway/            Main loop, message routing, commands
container/          Docker spawn, volume mounts, sidecars, runtime, skills seeding
ant/                In-container agent (TypeScript entrypoint + skills)
  skills/           Agent-side skills seeded into ~/.claude/skills/
queue/              Per-group concurrency, stdin piping
router/             Message formatting, routing rules
compose/            Docker-compose generation from *.toml service configs
ipc/                MCP server (unix socket per group, runtime auth via auth)
diary/              YAML frontmatter diary annotations
groupfolder/        Group path resolution and validation
mountsec/           Mount allowlist validation
chanlib/            Shared HTTP + auth primitives for channel adapters
grants/             Grant rule engine
notify/             Operator notification fan-out
gated/              Gateway daemon entrypoint
timed/              Scheduler daemon
onbod/              Onboarding daemon
dashd/              Operator dashboards
proxyd/             Web proxy
teled/              Telegram adapter
discd/              Discord adapter
mastd/              Mastodon adapter
bskyd/              Bluesky adapter
reditd/             Reddit adapter
emaid/              Email adapter
whapd/              WhatsApp adapter (TypeScript)

Data directory layout

/srv/data/arizuko_foo/
  .env                            config (gateway reads from cwd)
  store/
    messages.db                   SQLite database
  groups/
    <folder>/                     one directory per group
      CLAUDE.md                   agent instructions
      SOUL.md                     agent persona
      diary/                      dated diary entries
      episodes/                   archived session transcripts
      facts/                      freeform injected knowledge
      users/                      per-sender JID files
      logs/                       container run logs
      media/                      received media files
  data/
    ipc/
      <folder>/
        gated.sock                MCP unix socket
        sidecars/<name>.sock      sidecar MCP sockets
  web/
    pub/                          public web apps (served at /pub/)
    vhosts.json                   virtual host map (reloaded every 5s)
  services/
    *.toml                        additional compose service definitions