Structured state layer for local-first systems.
The metadata module is the memory of Softadastra.
It maintains a structured, queryable view of the system state, independent from:
- The filesystem (fs)
- The operation log (wal)
- The network (transport)
The goal of softadastra/metadata is simple:
Maintain the current known state of files, devices, and synchronization.
WAL stores what happened. Metadata stores what is known.
- WAL = history
- Metadata = current state
The metadata module provides:
- File state tracking
- Device state tracking
- Sync state tracking
- Version mapping
- Queryable state access
- No filesystem observation (fs module)
- No durability log (wal module)
- No network communication (transport module)
- No sync decision logic (sync module)
π It stores state, nothing more.
Metadata is derived from:
- WAL replay
- Sync operations
The state must always be:
- Internally consistent
- Queryable
- Recoverable
- WAL = append-only log
- Metadata = mutable structured state
Metadata exists to answer:
- What files do we have?
- What version is this file?
- What is synced or pending?
modules/metadata/
βββ include/softadastra/metadata/
β βββ FileEntry.hpp
β βββ DeviceState.hpp
β βββ SyncState.hpp
β βββ MetadataStore.hpp
β βββ SqliteMetadataStore.hpp
βββ src/
Represents a file in the system.
Contains:
- Path
- Hash
- Version
- Size
- Last modified
- Sync status
Represents a peer/device.
Contains:
- Device ID
- Last seen
- Known sequence
- Connection state
Tracks synchronization status.
Examples:
- Synced
- Pending
- Out-of-date
Abstract interface.
Provides:
- Read/write operations
- Queries
- State updates
Concrete implementation using SQLite.
Provides:
- Persistent state
- Query capabilities
- Transaction safety
#include <softadastra/metadata/SqliteMetadataStore.hpp>
using namespace softadastra::metadata;
SqliteMetadataStore store("data/metadata.db");
auto file = store.getFile("/docs/file.txt");
if (!file)
{
// create entry
}Used by:
- sync (primary)
- wal (indirect via replay)
- app layer
Tracks:
- Current version
- Content hash
- Sync status
Tracks:
- Known peers
- Last sync point
- Availability
Tracks:
- Pending operations
- Applied operations
- Missing operations
- WAL is replayed
- Metadata is rebuilt or updated
- Sync resumes from consistent state
- softadastra/core
- SQLite (initial implementation)
- Single device state tracking
- Basic file entries
- Simple sync status
- No advanced indexing
- Indexed queries (performance)
- Multi-device state optimization
- Conflict metadata
- Snapshot support
- In-memory cache layer
- Alternative storage backends
- Never act as a source of truth
- Never replace WAL
- Always reflect current known state
- Always remain queryable
Metadata is not truth.
It is a projection of truth.
- Stores structured state
- Enables queries
- Supports sync decisions
- Complements WAL
See root LICENSE file.