Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7.4 KiB
sidebar_position, title, description
| sidebar_position | title | description |
|---|---|---|
| 1 | Architecture Overview | Understanding Beads' three-layer data model |
Architecture Overview
This document explains how Beads' architecture works with Dolt as its storage backend.
Architecture
Beads uses Dolt as its sole storage backend -- a version-controlled SQL database that provides git-like semantics (branch, merge, diff, push, pull) natively at the database level.
By default, Dolt runs in embedded mode (in-process, no separate server). For multi-writer
setups (multiple agents, orchestrator), switch to server mode which connects to a
running dolt sql-server. See the Dolt Server Mode section below for details.
flowchart TD
subgraph DOLT["๐๏ธ Dolt Database"]
D[(".beads/dolt/<br/><i>Version-Controlled SQL</i>")]
end
subgraph REMOTE["๐ Dolt Remotes"]
R[("DoltHub / S3 / GCS<br/><i>Sync & Backup</i>")]
end
D <-->|"bd dolt push/pull"| R
U((User)) -->|"bd create<br/>bd update"| D
D -->|"bd list<br/>bd show"| U
style DOLT fill:#2d5a27,stroke:#4a9c3e,color:#fff
style REMOTE fill:#1a4a6e,stroke:#3a8ac4,color:#fff
:::info Source of Truth Dolt is the source of truth. Every write auto-commits to Dolt history, providing full version control, branching, and merge capabilities at the database level.
Recovery is straightforward: pull from a Dolt remote with bd dolt pull, or restore from a Dolt-native backup with bd backup restore.
:::
Why Dolt?
- Version-controlled SQL: Full SQL queries with native version control
- Cell-level merge: Concurrent changes merge automatically at the field level
- Multi-writer: Server mode supports concurrent agents
- Native branching: Dolt branches independent of git branches
- Works offline: All queries run against local database
- Portable:
bd exportproduces JSONL for migration and interoperability
Data Flow
Write Path
User runs bd create
โ Dolt database updated
โ Auto-committed to Dolt history
Read Path
User runs bd list
โ Dolt SQL query
โ Results returned immediately
Sync Path
User runs bd dolt push
โ Commits pushed to Dolt remote
User runs bd dolt pull
โ Remote commits fetched and merged
Multi-Machine Sync Considerations
When working across multiple machines or clones:
-
Always sync before switching machines
bd dolt push # Push changes before leaving -
Pull before creating new issues
bd dolt pull # Pull changes first on new machine bd create "New issue" -
Avoid parallel edits - If two machines create issues simultaneously without syncing, Dolt's cell-level merge handles most conflicts automatically
See Sync Failures Recovery for data loss prevention in multi-machine workflows (Pattern A5/C3).
Dolt Server Mode
The Dolt server handles background synchronization and database operations:
- Manages the Dolt database backend
- Handles auto-commit for change tracking
- Provides concurrent access for multiple agents
- Logs available at
.beads/dolt/sql-server.log
:::tip
Start the Dolt server with bd dolt start. Check health with bd doctor.
:::
Embedded Mode (No Server)
For CI/CD pipelines, containers, and single-use scenarios, no server is needed. Beads operates in embedded mode automatically when no Dolt server is running:
bd create "CI-generated issue"
bd dolt push
When embedded mode is appropriate:
- CI/CD pipelines (Jenkins, GitHub Actions)
- Docker containers
- Ephemeral environments
- Scripts that should not leave background processes
Multi-Clone Scenarios
:::warning Race Conditions in Multi-Clone Workflows When multiple git clones of the same repository run sync operations simultaneously, race conditions can occur during push/pull operations. This is particularly common in:
- Multi-agent AI workflows (multiple Claude/GPT instances)
- Developer workstations with multiple checkouts
- Worktree-based development workflows
Prevention:
- Stop the Dolt server (
bd dolt stop) before switching between clones - Dolt handles worktrees natively in server mode
- Use embedded mode for automated workflows :::
See Sync Failures Recovery for sync race condition troubleshooting (Pattern B2).
Recovery Model
Dolt's version control makes recovery straightforward:
- Lost database? โ Pull from Dolt remote:
bd dolt pull - Have a backup? โ Restore it:
bd backup restore [path] --force - Merge conflicts? โ Dolt handles cell-level merge natively
Universal Recovery Sequence
The following sequence resolves the majority of reported issues. For detailed procedures, see Recovery Runbooks.
bd dolt stop # Stop Dolt server (prevents race conditions)
git worktree prune # Clean orphaned worktrees
bd dolt pull # Pull from Dolt remote
bd dolt start # Restart server
:::warning Use bd doctor --fix With Care
Always back up and preview before running bd doctor --fix:
- Back up first:
cp -r .beads .beads.backup - Preview changes:
bd doctor --dry-runโ shows what would be fixed without making changes - Review diagnostics:
bd doctor(no flags) โ diagnostic only, no changes made - Then fix:
bd doctor --fixโ orbd doctor --fix -ito confirm each fix individually
Why caution? The --fix flag may remove dependencies it flags as circular, including valid parent-child relationships. Use --fix-child-parent only if you're certain the flagged deps are invalid.
Other diagnostic tools:
bd blockedโ check which issues are blocked and whybd show <issue-id>โ inspect a specific issue's state :::
See Recovery for specific procedures and Database Corruption Recovery for Dolt recovery steps.
Design Decisions
Why Dolt?
Dolt is a version-controlled SQL database that provides git-like semantics natively. Unlike plain SQLite (binary merge conflicts) or JSONL (slow queries), Dolt gives you both fast SQL queries and proper merge semantics.
Why not a cloud server?
Beads is designed for offline-first, local-first development. The Dolt server runs locally -- no cloud dependency, no downtime, no vendor lock-in, and full functionality on airplanes or in restricted networks.
Trade-offs
| Benefit | Trade-off |
|---|---|
| Works offline | No real-time collaboration |
| Version-controlled database | Requires Dolt server |
| Cell-level merge | Requires initial setup |
| Local-first speed | Manual sync to remotes |
| SQL queries | Dolt binary dependency |
When NOT to use Beads
Beads is not suitable for:
- Large teams (10+) โ Git-based sync doesn't scale well for high-frequency concurrent edits
- Non-developers โ Requires Git and command-line familiarity
- Real-time collaboration โ No live updates; requires explicit sync
- Cross-repository tracking โ Issues are scoped to a single repository
- Rich media attachments โ Designed for text-based issue tracking
For these use cases, consider GitHub Issues, Linear, or Jira.
Related Documentation
- Recovery Runbooks โ Step-by-step procedures for common issues
- CLI Reference โ Complete command documentation
- Getting Started โ Installation and first steps