> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bossmode.ing/llms.txt
> Use this file to discover all available pages before exploring further.

# Local SQLite

> The local SQLite brain is BossMode's offline-capable data layer. Here's how it's structured and how to work with it directly.

<Warning>🚧 Expanding soon — full Local SQLite documentation is in progress.</Warning>

## What is the local brain?

When you run `bossmode init`, the CLI seeds a local SQLite database at `~/.bossmode/brain.db`. This database stores:

* Your standing orders
* Buyer profiles and voice calibration
* Directive history and audit feed
* Agent execution logs
* Local signal cache
* Guardian state

The local brain is the single source of truth for local-mode operation. In cloud-connected mode, it syncs bidirectionally with your Convex instance.

## Database location

```
~/.bossmode/brain.db
```

The directory also contains:

```
~/.bossmode/
  brain.db          # SQLite database
  config.json       # CLI configuration
  logs/             # Execution logs
  exports/          # Report exports
```

## Schema overview

The local brain mirrors the Convex schema. Key tables:

| Table             | Description                            |
| ----------------- | -------------------------------------- |
| `standing_orders` | Active and archived standing orders    |
| `directives`      | All issued directives and their status |
| `agent_moves`     | Individual capo execution log          |
| `approvals`       | Approval gate queue                    |
| `signals`         | Ingested and scored signals            |
| `buyer_profiles`  | AvatarCzar buyer models                |
| `audit_feed`      | Full immutable audit log               |
| `daily_reports`   | Generated report cache                 |

## Direct SQLite access

For power users who want to query directly:

```bash theme={null}
sqlite3 ~/.bossmode/brain.db

# List recent directives
SELECT id, directive, capo, status, created_at
FROM directives
ORDER BY created_at DESC
LIMIT 10;

# Count approvals by status
SELECT status, COUNT(*) FROM approvals GROUP BY status;
```

## Backup and restore

```bash theme={null}
# Backup
bossmode backup --output ~/bossmode-backup-$(date +%Y%m%d).db

# Or direct SQLite copy
cp ~/.bossmode/brain.db ~/bossmode-backup.db

# Restore
bossmode restore --input ~/bossmode-backup.db
```

## Sync to cloud

When you add your operator token, the local brain syncs to Convex automatically:

```bash theme={null}
bossmode sync --token $BOSSMODE_API_TOKEN
```

Sync is bidirectional. Local changes propagate to cloud. Cloud changes (from other devices or the web app) propagate locally.

## SQLite to Convex

The Convex schema in `convex/schema.ts` mirrors the SQLite structure. If you fork BossMode and modify the schema, update both to keep sync working.
