SQLite DB & State Management
Relevant source files
The following files were used as context for generating this wiki page:
Rebase employs a multi-layered state management system that combines a centralized SQLite database for structured data with local Markdown and JSON files for agent-specific persistence and configuration. The architecture ensures that both the Tauri-based production app and the experimental Rust/GPUI native app share a consistent state.
Database Architecture
The primary data store is a SQLite database named rebase.db, located within the application data directory under the identifier com.rebase.desktop. This database is shared between the GPUI native crate and the Tauri frontend to prevent state drift.
Sources: crates/rebase-core/tests/shared_contracts.rs:64-74, crates/rebase-core/Cargo.toml:13
The Notes Module
Notes are managed through a dedicated schema within rebase.db. The system handles full-fidelity desktop notes, including metadata for slugs, tags, and session associations.
The following diagram illustrates the notes table structure:
The notes table includes indices on updated_at and id to optimize list retrieval for the composer.
Sources: crates/rebase-core/src/store/notes.rs:21-45
CRUD Operations and Normalization
Rebase enforces strict constraints and normalization during note state updates:
- Slug Generation: Automatically generates unique, URL-friendly slugs from titles using lowercase ASCII words joined by hyphens. Sources: crates/rebase-core/src/store/notes.rs:240-255
- Tag Normalization: Trims whitespace, removes leading '#' characters, and converts tags to lowercase, limiting each tag to 48 characters and 20 tags per note. Sources: crates/rebase-core/src/store/notes.rs:205-227
- Size Constraints: Limits note bodies to a maximum size defined by
MAX_BODY. Sources: crates/rebase-core/src/store/notes.rs:319-322
File-Based State Management
Certain agent-specific and configuration states are persisted directly as files rather than database rows. This is primarily used for Pilot agents and third-party integrations.
Pilot Agents Persistence
Pilots maintain a "Soul" and "Memory" persisted in the pilots/ directory within the application data folder.
| File Type | Filename | Description |
|---|---|---|
| Soul | SOUL.md | Contains standing instructions and identity. |
| Memory | MEMORY.md | Fact-based storage updated via the CLI. |
| Topics | memory/<topic>.md | Specific detailed notes referenced by the agent. |
Sources: src/features/pilots/model/pilotFiles.ts:13-35, crates/rebase-core/tests/shared_contracts.rs:136-138
Configuration State
Configurations for SCM providers (like GitLab) and Skills are stored as JSON files in the app data directory.
- GitLab Config: Stored in
gitlab-config.jsonwith restricted file permissions (0o600 on Unix) to protect private tokens. Sources: src-tauri/src/gitlab.rs:775-789, src-tauri/src/gitlab.rs:807-825 - Claude Plugins: Discovered via
installed_plugins.jsonlocated in~/.claude/plugins/. Sources: src-tauri/src/skills.rs:188-195
State Synchronization Flow
Rebase coordinates state between the UI and the underlying storage using an asynchronous command pattern.
Citations: src/features/pilots/model/pilotFiles.ts:145-156, src-tauri/src/gitlab.rs:94-118
Pilot Context Planning
To manage the state sent to AI models, Rebase uses a context versioning system. It calculates a "Context Plan" to determine if the SOUL.md or MEMORY.md needs to be resent to the provider based on hash changes.
Sources: src/features/pilots/model/pilotFiles.ts:212-230
External State Discovery
The application dynamically scans specific system paths to build its internal state for available "Skills":
- Project Scope: Scans
.agents/skillsin the current working directory. - User Scope: Scans
~/.agents/skillsand provider-specific folders (e.g.,.claude/skills,.cursor/skills). - Plugin Scope: Parses Claude plugin registries to namespace and inject external skills.
Sources: src-tauri/src/skills.rs:114-165
SQLite DB & State Management in Rebase provides a unified persistence layer that bridges high-performance structured storage in Rust with flexible, human-readable Markdown files, ensuring agent consistency across different runtime environments.