Repository navigation
Backend Services
Canonical source:
context/service-catalog.md— this page is rendered from it on every publish; edit the source.
One entry per backend service. Derived from .ai/manifests/services.json
(path, port, DB, models, deps), event-graph.json (produced/consumed events),
api-endpoints.json (routes), and nginx-routes.json (gateway prefix). When any
of these drift, regenerate the manifests and update this file.
Last verified: 2026-10-04.
Every service depends on @claw/shared-constants, @claw/shared-types,
@claw/shared-utilities (health depends on shared-utilities only); most also on
@claw/shared-rabbitmq and @claw/shared-entitlements. Only agent, payment,
research, and workspace add @claw/shared-auth. All 17 non-health services publish
log.server.
-
Path:
apps/claw-auth-service· Gateway:/api/v1/auth,/api/v1/users,/api/v1/admin - Owns: User, Session, Role, RolePermission, Plan, PlanModelAccess, UserPlanAssignment, TokenUsageLedger, SystemSetting
-
Responsibility: JWT + refresh-token rotation (argon2), RBAC roles/permissions, plans & entitlements, quota reserve/finalize/release (
/internal/quota/*), user CRUD. -
Produces:
user.created,user.deactivated,user.login,user.logout,user.role_changed. -
Pitfalls: identity/permission changes are the authentication-security pack — read
rules/08-security-rules.md. Quota endpoints are internal-only.
-
Path:
apps/claw-chat-service· Gateway:/api/v1/chat-threads,/api/v1/chat-messages - Owns: ChatThread, ChatMessage, ChatMessageContextReceipt, MessageAttachment, FileDeliveryRecord
-
Responsibility: threads/messages, context assembly (pulls memories, context packs, file chunks over HTTP), execution + fallback, SSE streaming (
stream/:threadId), multi-model modes (parallel, best-of-n, consensus, cost-ensemble, decompose, escalation-chain, pipeline, role-pack, verify, repair). -
Produces:
message.created,message.completed,message.routed(consumed),message.feedback_set,context.receipt_written,chat_thread.memory_toggled,chat_thread.context_toggled. -
Consumes:
message.routed(from routing). -
Pitfalls: SSE routes need
@SkipLogging(),@SkipThrottle(), and nginxproxy_buffering off. When all providers fail you MUST store an error ASSISTANT message or the frontend polls forever (seeCLAUDE.md"Fallback & Error Handling").
-
Path:
apps/claw-connector-service· Gateway:/api/v1/connectors,/api/v1/models - Owns: Connector, ConnectorModel, ConnectorHealthEvent, ModelSyncRun
-
Responsibility: 7 cloud/local providers, AES-256-GCM-encrypted config, health checks, model sync,
/internal/connectors/configfor other services. -
Produces:
connector.created/updated/deleted,connector.synced,connector.health_checked. - Consumers of its events: audit + routing (synced, health_checked).
-
Pitfalls: never expose
encryptedConfig/API keys in responses. Vendor SDKs go in adapters only.
-
Path:
apps/claw-routing-service· Gateway:/api/v1/routing - Owns: RoutingDecision, RoutingPolicy, RouterModelRegistry/Profile/Topic/Learned scores, ReplayRun/Case, RouterCircuitBreaker, RoutingFeedback/Outcome records, TaxonomyRole, and more (14 models).
- Responsibility: 5-stage AUTO pipeline (privacy → image → file → category → Ollama/heuristic), 7 routing modes, policies, replay lab, circuit breakers, learning loop.
-
Produces:
routing.models.synced, plus routing profile/circuit-breaker lifecycle events. -
Consumes:
message.created,message.completed,connector.synced/health_checked,model.pulled/deleted,llamacpp.model.loaded/unloaded/crashed, routing profile events. Publishesmessage.routedback to chat. - Pitfalls: model-routing pack; largest endpoint surface after workspace (57). Router prompt is built dynamically from installed models (5-min TTL cache).
-
Path:
apps/claw-memory-service· Gateway:/api/v1/memories,/api/v1/context-packs,/api/v1/context,/api/v1/memory - Owns: MemoryRecord, MemorySuggestion, MemoryUsage, MemoryAuditLog, MemoryPreference, ContextPack(+Item/Version/Usage/Attachment/Template), WorkspaceObjectEmbedding
-
Responsibility: memory CRUD + suggestion queue, extraction, sensitivity classification, retrieval bundle (
/internal/memories/retrieve), context packs V2. -
Produces:
memory.extracted/suggested/approved/rejected/used/forgotten/redacted,context_pack.version_created/version_reverted. -
Consumes:
message.completed(extraction). - Pitfalls: MEMORY_V2/CONTEXT_V2/RETRIEVAL_V2 flags gate behavior; retrieval token guard.
-
Path:
apps/claw-file-service· Gateway:/api/v1/files - Owns: File, FileChunk
-
Responsibility: upload + 4-check security (ClamAV, magic bytes, filename, ZIP bomb), chunking (JSON/CSV/MD/text), OCR (optional), retention sweep,
/internal/files/*for chat/image. -
Produces:
file.uploaded/chunked/deleted/downloaded/failed,file.upload_started/completed,file.ocr_started/completed/failed,file.extraction_failed,file.retention_expired,file.archive_expanded. - Pitfalls: ClamAV fail-safe rejects on scanner down; ZIP guardrails run before extraction.
-
Path:
apps/claw-audit-service· Gateway:/api/v1/audits,/api/v1/usage - Owns: AuditLog, UsageLedger (Mongoose)
- Responsibility: the near-universal event consumer — records audit events + usage/cost/latency ledger.
- Consumes: almost every lifecycle event (agent capability, ai_action, connector, file, llamacpp, memory, message.completed, routing, user, workspace sync/action). See event-flow-map.md.
- Pitfalls: consumer-heavy; handlers must not swallow errors.
-
Path:
apps/claw-ollama-service· Gateway:/api/v1/ollama - Owns: LocalModel, LocalModelRoleAssignment, ModelCatalogEntry, ModelDiscovery(Run/Candidate/Source), PullJob, RuntimeConfig
- Responsibility: local model management, roles (ROUTER/CODING/…), catalog (142 models), pull jobs (SSE progress), generation, discovery.
-
Produces:
connector.synced,connector.updated(syncs local models as a connector). Gated bylocal-aicompose profile. -
Pitfalls: only runs when
--local-aiis enabled; ROUTER-role models are excluded from user model selectors.
-
Path:
apps/claw-health-service· Gateway:/api/v1/health -
Owns: nothing. Depends only on
@claw/shared-utilities. -
Responsibility: aggregates
/healthfrom all services. New services must be added to its check list.
-
Path:
apps/claw-client-logs-service· Gateway:/api/v1/client-logs - Owns: ClientLog (Mongoose, TTL 30d)
- Responsibility: batched frontend log ingestion + stats.
-
Pitfalls: no
*_SERVICE_PORTconstant — port isCLIENT_LOGS_PORTenv-only. Flagged in the inventory audit. See port-and-service-map.md.
-
Path:
apps/claw-server-logs-service· Gateway:/api/v1/server-logs - Owns: ServerLog (Mongoose, TTL 30d)
-
Responsibility: consumes
log.serverfrom all 17 non-health services; Elasticsearch-ready backend log viewer. -
Pitfalls: no port constant — port is
SERVER_LOGS_PORTenv-only.
-
Path:
apps/claw-image-service· Gateway:/api/v1/images - Owns: ImageGeneration, ImageGenerationAsset, ImageGenerationEvent
-
Responsibility: image generation (OpenAI gpt-image-1/Gemini/xAI/SD/ComfyUI adapters), owner-only retry/retry-alternate + owner-guarded SSE
/images/:id/events, service-token-guarded/internal/images/*, SSE progress (SD WebUI + ComfyUI adapters). -
Pitfalls:
image.generated/image.failedpatterns declared; ComfyUI/SD gated bylocal-ai.
-
Path:
apps/claw-file-generation-service· Gateway:/api/v1/file-generations - Owns: FileGeneration, FileGenerationAsset, FileGenerationEvent
-
Responsibility: file export (PDF/DOCX/CSV/HTML/MD/TXT/JSON), retry,
/internal/file-generations/generate.
-
Path:
apps/claw-workspace-service· Gateway:/api/v1/workspace - Owns: 25 models — WorkspaceConnector(+Grant), WorkspaceObject(+Link/Embedding), WorkspaceSyncRun, WorkspaceChain(+Run/Step), AiActionPolicy/ApprovalQueue, WebhookDelivery, AutoSuggestRun, SuggestionTriggerRule/Deduplication, DigestSnapshot, and more.
- Responsibility: 12 workspace connectors (GitHub, GitLab, Jira, Slack, Drive, OneDrive, SharePoint, Confluence, Figma, Gmail, Bitbucket, ClickUp), OAuth2/PKCE, webhooks, scheduled sync, AI actions with approval queue, auto-suggest.
-
Produces: the largest event set —
workspace.sync.*,workspace_action.*,workspace_connector.*,workspace_object.synced,ai_action.*,workspace.auto_suggest.*,workspace.webhook.*,memory.preference.upserted. - Pitfalls: largest service (103 endpoints, the most test files); security-sensitive (OAuth secrets, webhook signatures).
-
Path:
apps/claw-agent-service· Gateway:/api/v1/agent - Owns: AgentSession, Device, PairingRequest, DeviceCodeRequest, RefreshToken, TerminalCommand, ScheduledCommand, CapabilityInvocation, AccessPolicy, Recipe(+Run/Step), ActivityMemoryEntry, AgentSuggestion, LocalRepo, FileWatchEvent, Marketplace(Listing/Install), Organization(+Member)
-
Responsibility: desktop agent — device pairing/auth, terminal command approval, capability framework (filesystem/process/…), recipes, fleet/org, marketplace, activity memory. Imports
@claw/shared-auth. -
Produces:
agent.session_connected/disconnected,agent.device_paired/revoked,agent.token_rotated/reuse_detected,agent.policy_violated,agent.command_*,agent.mobile_action,agent.capability.*(12 patterns). - Pitfalls: every capability needs a DeviceScope + default AccessPolicy + audited event; no silently allowed actions.
-
Path:
apps/claw-research-service· Gateway:/api/v1/research - Owns: SearchProvider, SearchRun, ResearchRun, FetchJob, PageCache
-
Responsibility: dynamic search/fetch/scrape/clone + evidence orchestration (Tavily, SearXNG, Ollama Web). Imports
@claw/shared-auth.
-
Path:
apps/claw-llamacpp-service· Gateway:/api/v1/llamacpp - Owns: FrontierCatalogEntry, BinaryRelease, PullJob, HardwareSnapshot, ModelLoadEvent, PreflightOverrideAudit, RuntimeConfig
- Responsibility: local frontier LLMs via vanilla llama.cpp — binary lifecycle, HF pull jobs (SSE), single-resident process supervisor, OpenAI-compatible inference proxy, hardware preflight.
-
Produces:
llamacpp.binary.installed/updated,llamacpp.pull.*,llamacpp.model.loaded/unloaded/crashed(routing consumes these),llamacpp.weights.deleted,llamacpp.preflight.overridden. -
Pitfalls: base image MUST be Debian (
node:20-bookworm-slim) — release binaries are glibc-linked.LLAMACPP_DATA_PATHmust live in the named volume. Has GPU overlays in compose.
-
Path:
apps/claw-payment-service· Gateway:/api/v1/payments,/api/v1/billing,/api/v1/admin/billing - Owns: BillingCustomer, CheckoutSession, FxQuote, GatewayPlanMapping, IdempotencyRecord, InboxEvent, Invoice, InvoiceDelivery, InvoiceLine, OutboxEvent, PaymentMethod, PaymentTransaction, ProrationQuote, ReconciliationDivergence, ReconciliationRun, Refund, SeedExecution, Subscription, WebhookEvent
- Responsibility: PayPal and Paymob checkout/payment-method setup, subscriptions, immutable invoices, refunds, lifecycle sweeps, reconciliation, and the admin billing dashboard.
- Produces: billing subscription, payment, invoice, refund, and entitlement lifecycle events through the transactional outbox.
- Calls: auth internal plan/entitlement and provider-cost contracts; auth consumes payment events to project subscription state and revoke entitlements.
-
Pitfalls: keep money in integer minor units or microUSD, keep
/internal/*off nginx, use owner-token locks for scheduled jobs, and treat prices, refunds, and invoice snapshots as immutable records.
-
Path:
apps/claw-threads-service· Gateway:/api/v1/thread-publications -
Owns:
claw_threadsPostgreSQL; publications, immutable revisions, comments, reactions, change requests, and reports. -
Responsibility: owner publication lifecycle and authenticated community actions; report moderation requires
THREAD_PUBLICATIONS_MODERATE. Account deletion cleanup and community UI remain pending; see Threads architecture.
-
Path:
apps/claw-thread-generation-service· Gateway: internal only -
Owns:
claw_thread_generationPostgreSQL; durable jobs, attempts, checkpoints, evidence, model outputs, and private revision drafts. -
Responsibility: service-token-only enqueue/cancel routes; dedicated
claw.threads.generationworker; research, author consensus, Judge, and Critic pipeline. Publication read/approval handoff is pending.
-
Path:
apps/claw-plugin-service· Gateway:/api/v1/plugins(its/api/v1/internal/*routes are closed at the edge) -
Owns:
claw_pluginPostgreSQL; the plugin catalog (seeded first-party manifests),PluginSettingadmin settings, user installs with tool consents and write-only credentials, and the invocation audit table (MCP servers arrive later). -
Responsibility: Catalog (browse and detail), per-user installs under the plan cap, tool consent, write-only API-key credentials, admin kill switch and settings, and the
user.deletedpurge. Chat-service is the only future caller of the internal routes. Credentials use the separatePLUGIN_ENCRYPTION_KEY, checked at boot (ADR-172). Design: plugins-and-mcp-design.
ClawAI Wiki · source-controlled under wiki/ · generated/mirrored from the current repository knowledge layer.
ClawAI Wiki
Product
- Product-Vision
- Flagship-Features
- Business-Overview
- Requirements-Register
- Drift-Log
- Runtime-Managed-Connector-Providers
- Threads
- ADR-Index
Architecture
- System-at-a-Glance
- Architecture-Map
- System-Architecture
- Message-Flow
- End-to-End-Data-Flow
- Routing-Engine
- Event-Bus
- Security-Architecture
Platform
- Backend-Services
- Frontend-Architecture
- Shared-Packages
- Database-Reference
- API-Reference
- Provider-Catalog
- Memory-and-Context-Architecture
- File-Support-Architecture
- Research-and-Web-Crawling
Runtime & Ops
- Docker-Guide
- Nginx-Reference
- CI-CD-Pipeline
- Logging-and-Observability
- Operational-Runbooks
- Troubleshooting
Quality
Engineering OS
- AI-Native-Engineering-OS
- Generated-Manifests
- Rules-Catalog
- Skills-Catalog
- Context-Layer
- Engineering-Memory
- Tooling-and-Automation
- Scripts-and-Operations
- ESLint-and-Architecture-Enforcement
- Extended-Work-Skills
Agents
Reference