Skip to content

Architecture ​

How Jarvis is built. Status: iteration 1 is implemented (engine, web, server readiness); the current state and the live-proof gaps are in ../../STATUS.md. The why behind each choice is in ../decisions/architecture/ (accepted); behaviour is in ../specs/abstract-project-spec.md; the UI brief is in ../specs/web-ui-design.md.

System context ​

Everything runs on one machine: the owner's laptop, or a VPS reached only over Tailscale (ADR-0016). The engine is one Node process; it spawns claude processes and talks to GitHub. Postgres runs in Docker. Slack arrives in iteration 2.

Modules ​

ModulePathPurpose
sharedshared/Zod contracts: HTTP bodies, SSE events, MCP tool inputs, config schema, enums (stages, roles)
engineengine/Onion: domain, application, infrastructure, presentation (ADR-0002)
webweb/React SPA: chat + admin

Engine layers (ADR-0002):

LayerMain parts
DomainThread, Message, Task + stage transitions, Run, Watch, PermissionRequest, LimitPolicy
ApplicationUse cases: PostOwnerMessage, StartTask, ApproveSpec, AnswerQuestion, AnswerPermission, HandleCodeHostChange, ResumeTask, CancelTask, StopRun, RetryStage; scheduler of worker slots; ports
InfrastructureDrizzle repositories, ClaudeCliRunner (spawn, stream-json parse, env allow-list), GitWorktreeManager, GitHubCodeHost (Octokit), FileArtifactStore, config + env loaders, SSE fan-out
PresentationFastify routes + /api/stream, Jarvis MCP server (stdio, per run), watcher timer, Slack adapter (iteration 2)

How a task flows ​

Process model (ADR-0003) ​

  • Dispatcher run per owner message: claude -p --resume <thread-session> --output-format stream-json, dispatcher prompt, only Jarvis dispatcher tools.
  • Worker run per task stage: claude -p --input-format stream-json --output-format stream-json --verbose, cwd = task worktree, --max-turns, --max-budget-usd, --model, --mcp-config (Jarvis tools + connectors), --permission-prompt-tool mcp__jarvis__approve, worker settings that deny git push and gh, and no GitHub token in its environment: the engine runs the checks, pushes and opens the PR (ADR-0022).
  • Owner messages to a live worker go to its stdin; otherwise they wait for the next run.
  • Every stream-json event is stored in run_events and pushed over SSE — that is the admin "console".
  • The engine refuses to start with ANTHROPIC_API_KEY set and strips provider variables from child env.

Data (ADR-0008) ​

Postgres tables (indicative): threads, messages, tasks, task_events, runs, run_events, permission_requests, watches, usage. Artifacts: <dataDir>/tasks/<task-id>/*.md.

DELETE /api/threads/:id (DeleteThread, THR-DEL-01) is the only way rows leave these tables. It refuses (409) while a task of the thread is not terminal or a run is running; otherwise one transaction removes the thread's run events, permission requests, runs, sessions, watches, journal rows, messages, tasks and the thread, children first (ThreadRepository.deleteWithContents), and the tasks' artifact folders go after the commit. The append-only triggers on task_events and run_events let a DELETE through only in a transaction that set jarvis.purge_journals (migration 0011). Branches, worktrees and PRs stay.

DELETE /api/threads/:threadId/messages/:messageId (DeleteMessage, THR-DEL-02) deletes one messages row. It is 404 for a message of another thread and 409 for a card with no answer. Nothing references a message by key and the journals are not touched; queued owner input is read from messages when a run starts, so a deleted queued message is never delivered.

Where agent data lives (ADR-0009) ​

WhatWhereIn git
Agent definition: SOUL.md, role prompts, subagents, skills, SDD templates, permission settingsagent/ — a Claude Code plugin loaded per run with --plugin-diryes
Owner preferences USER.md, jarvis.config.json, .env, mcp/servers.json~/.jarvis/no (examples only)
Worktrees, SDD artifacts, screenshots, per-run mcp.json/settings.json~/.jarvis/worktrees, tasks, runsno
Threads, messages, tasks, journal, runs, run events, permissions, watches, usagePostgresno
Claude session transcripts and the subscription login~/.claude (managed by Claude Code); Jarvis stores only session_idno
Project rules and check commandstarget repo AGENTS.mdtarget repo
The owner's own skills and subagents (ADR-0025)~/.jarvis/plugin — a second plugin, also loaded per run; backups in ~/.jarvis/plugin-backupsno

Runs use --setting-sources project,local so the owner's personal ~/.claude plugins and hooks do not leak into the agent, and --mcp-config ... --strict-mcp-config so only Jarvis and connector servers load. The exception is a run given the owner's claude.ai connectors (connectors.claudeAi, ADR-0027): those exist only for a run that is not strict and reads the user source too, so such a run allows the connectors' read tools by name and denies the rest — and does see the owner's ~/.claude plugins and hooks on that machine. The owner's skills and subagents are written only by the Capabilities page through the owner's HTTP API, never by an agent tool; the page also lists the built-in, repository and MCP capabilities read-only (ADR-0025, agent-capabilities). Visual overview: overview.html, published at https://claude.ai/artifact/DwL6g8WNwwMThtbhqgZztn

Configuration and secrets (ADR-0005, ADR-0015) ​

  • ~/.jarvis/jarvis.config.json (example committed): repo, limits, models per role, allowlists, connector scopes.
  • Secrets live in Infisical (ADR-0015), with ~/.jarvis/.env as the local fallback (example committed): GITHUB_TOKEN of the bot account, NOTION_TOKEN, Google OAuth credentials, DATABASE_URL, POSTGRES_PASSWORD; iteration 2 adds SLACK_BOT_TOKEN, SLACK_APP_TOKEN.
  • Claude: the owner logs in with claude once; no key in Jarvis.
  • On a server, secrets come from Infisical (ADR-0015); see deployment.md.
  • How connectors (Notion, Google Docs) authenticate without a browser on the server: connectors.md.

Deployment (ADR-0016) ​

The laptop setup stays the default. For an always-on setup, Jarvis runs on a Hetzner VPS as systemd services, reachable only over Tailscale: deployment.md.

Iterations ​

IterationAdds
1engine, Postgres, web chat + admin, dispatcher and worker runs, SDD flow, connectors, GitHub bot + watcher, limits config
2Slack adapter with threads (Socket Mode), permission and decision buttons as Block Kit actions