Introducing a new way to review your PRs.

Read the announcement

fwdai / rowel

🔑 Local-first Secrets Manager

View on GitHub

23 documents · Updated Oct 9, 2026

docs / vault-data-and-sync

Vault data and synchronization

The vault is an encrypted store for sensitive entries that can move between this device and a connected Google Drive account. The system keeps secret fields protected at rest, exposes only the metadata needed for lists, and uses encrypted snapshots to restore and converge the same vault across workspaces and devices.

Vault data representation

Encrypted vault contents

The vault uses an encrypted SQLite database as its local source of truth. A vault key derived from the master password protects the database, entry payloads, and attached files through separate keys; current vaults use authenticated encryption for each protected object. The key-derivation description is stored beside the database because the app must read it before it can open the database. Legacy vaults remain readable through their older key scheme, but they do not support the current attachment storage path.

Each entry has a public-to-the-vault record and a protected payload. The record supports list views and sync decisions without opening the secret fields. The payload holds the full entry and is opened only when the user views or edits that entry. Payloads are bound to their entry IDs, so moving one sealed payload under another record does not make it valid.

References: src-tauri/…/vault.rs• L1-15 src-tauri/…/vault.rs• L50-80 src-tauri/…/vault.rs• L123-201 src-tauri/…/storage.rs• L11-22 src/…/types.ts• L151-182

Entry metadata

Entry metadata is the small view of a vault used by the list, archive, search, and sync status. It includes identity and display data such as the ID, kind, title, tags, host, timestamps, and selected derived flags. Secret values do not travel in this view. A reveal request opens one entry and returns a redacted form suitable for the web interface.

This split lets ordinary actions remain metadata-only. For example, changing a favorite does not open the protected payload, while saving an edited entry seals a new payload and updates its metadata as one record. Archived entries remain as tombstones so a delete can reach other devices before the row is later reclaimed.

References: src/…/types.ts• L151-182 src-tauri/…/vault.rs• L14-46 src-tauri/…/vault.rs• L82-125 src-tauri/…/sqlite.rs• L273-333

Vault persistence

Local vault state

The local database and its related files form one vault boundary. The database contains the encrypted records and vault identity. Sidecar files hold the key-derivation description, failed-unlock state, rekey recovery data, the wrapped workspace key, and the sealed provider credentials. The application keeps workspace labels and other device-only workspace facts outside the encrypted vault so it can show the workspace picker while the vault is locked.

Writes use durable replacement for small sidecar files. Database writes use a crash-safe write-ahead log. A vault move or workspace deletion must treat the database, its write-ahead-log siblings, key files, recovery files, and provider credentials as one unit; splitting them can leave a database that cannot open or a connection that points to the wrong vault.

On iOS, the vault can use the shared App Group container so the main app and its AutoFill extension open the same data. Data moves between the app container and the shared container as whole entries, which prevents two vaults from being combined after an interrupted move.

References: src-tauri/…/storage.rs• L11-79 src-tauri/…/storage.rs• L102-205 src-tauri/…/storage.rs• L330-469 src-tauri/…/sqlite.rs• L108-169

Open and save flow

Opening a vault derives or retrieves its key, opens the encrypted database, applies any known schema changes, and returns the entry metadata needed to render the main view. The frontend keeps this metadata in session state. Locking clears that session state so a later unlock cannot show rows from the previous vault.

Saving follows the reverse path. The frontend sends one completed entry to the native side, which restores protected credential material that must not enter the web view, seals the entry, and upserts one database row. A successful local write updates the visible list and asks the sync system to publish the new whole-vault state after a short delay.

The main lifecycle is intentionally separated from this overview in Vault lifecycle and persistence. It covers creation, password changes, unlock, lock, and close behavior in more detail.

References: src-tauri/…/vault.rs• L14-46 src/…/app.ts• L239-279 src/…/vault.ts• L107-165 src-tauri/…/sqlite.rs• L557-600

Workspace boundaries

Workspace vaults

A workspace is a separate encrypted vault with its own database, key, identity, and provider connection. Only one workspace database is open at a time. The app-level key ring can remember keys for workspaces already opened on the device, which allows a switch without another password prompt; a workspace that has never been opened still needs its own unlock.

The workspace registry records which workspaces exist, which one is active, and non-secret local labels. A vault ID is recorded when synchronization settles it. The vault ID identifies the shared data on the provider; the local workspace ID does not, because local IDs such as the primary workspace can repeat on different installations.

Every workspace has an independent sync state. Switching clears the old vault session before the new one is opened, and the app refreshes sync status for the newly active workspace. This keeps entries, provider credentials, and sync errors from crossing workspace boundaries.

The related Workspaces and synchronization page describes workspace creation, restore, selection, deletion, and provider controls.

References: src-tauri/…/workspace.rs• L1-11 src-tauri/…/workspace.rs• L27-70 src/…/workspace.ts• L4-13 src/…/workspace.ts• L38-70

Synchronization

Google Drive provider

Google Drive is the current remote provider. Each connected workspace stores its provider credentials sealed under that workspace's key and maps its vault ID to one remote pack in Rowel/Vaults. The account can hold several packs, one per vault, while the provider connection remains local to each workspace.

Connection starts with consent and an account probe. The probe lists all packs before the app adopts the account. An empty account can accept a new vault; an account that already contains this vault can add another device; an account containing only other vaults offers those vaults for restore instead of creating an unrelated second pack.

The provider is not a second plaintext database. It stores one encrypted .rowel pack per vault. The file name contains an opaque vault ID and does not expose the user's workspace label.

References: src-tauri/…/layout.rs• L1-22 src-tauri/…/sync.rs• L46-61 src-tauri/…/sync.rs• L87-113 src-tauri/…/mod.rs• L218-270

Encrypted vault packs

A .rowel pack is the exchange form for synchronization and local backup. Its small header contains a format marker and the public key-derivation description. The rest is an encrypted SQLCipher snapshot, so entry titles, hosts, counts, and payloads are not visible in the remote file.

The same pack is used for a first restore, a workspace restore, and a backup restore. A pack from another vault is rejected before it can merge. A malformed, truncated, or newer-format pack also stops the operation rather than changing the local vault.

References: src-tauri/…/pack.rs• L1-18 src-tauri/…/pack.rs• L96-161 src-tauri/…/engine.rs• L390-445 src-tauri/…/setup.rs• L240-265

Pull, merge, and push flow

Synchronization treats the remote pack as a full snapshot rather than as a stream of individual changes. A run pulls the current pack, merges its records into the local vault, compares the resulting state with the remote state, and uploads a new encrypted snapshot only when they differ. The merge uses a deterministic last-writer rule per entry, including tombstones, so different devices select the same winner and converge.

The flow below shows the relationship between the local vault, the provider, and the frontend status updates.

flowchart LR
    A[Local change or unlock] --> B[Schedule sync]
    B --> C[Resolve vault ID]
    C --> D[Pull encrypted pack]
    D --> E[Open temporary snapshot]
    E --> F[Merge records and tombstones]
    F --> G{Local and remote state differ?}
    G -- No --> H[Report success]
    G -- Yes --> I[Pack local encrypted database]
    I --> J[Upload one vault pack]
    J --> H
    H --> K[Publish status and changed metadata]

Local saves trigger a debounced run, and an unlock starts a run for a connected vault. A run already in progress is not duplicated; a later write leaves a request for one follow-up run. A remote revision check prevents a stale local snapshot from replacing a newer remote snapshot. If another device wins that race, the run pulls again and merges the union.

Deleted entries use tombstones so a delete can propagate. Very old tombstones are eventually reclaimed during packing, which limits growth but creates a known risk for a device that has stayed offline beyond that retention period.

References: src-tauri/…/engine.rs• L1-15 src-tauri/…/engine.rs• L147-261 src-tauri/…/sync.rs• L542-618 src/…/app.ts• L301-337 src-tauri/…/sqlite.rs• L365-385

Synchronization status

The native side owns provider consent, runs, errors, and timestamps. It reports the complete sync status through events rather than asking the frontend to rebuild state from a sequence of partial events. The frontend also receives refreshed entry metadata after a merge, then refreshes audit and archive views when needed.

The status belongs to the active workspace. A workspace switch publishes a new status snapshot before the new workspace is shown, and sequence numbers prevent an older probe result from replacing a newer event. A remote deletion marker stops a vault from recreating a pack that another device deleted everywhere; the user must remove that workspace locally before sync can continue.

References: src/…/sync.ts• L4-33 src/…/app.ts• L163-172 src/…/events.ts• L37-66 src-tauri/…/sync.rs• L454-538 src-tauri/…/mod.rs• L441-487

Import, export, and backup

Vault backup and restore

A .rowel backup is a user-selected copy of the same encrypted pack used by Drive. Export checks the supplied password against the open vault, then writes the encrypted snapshot without exposing its contents. A fresh install can restore the file through the same pack validation and key-derivation path used for a Drive restore.

The app reads a backup as a bounded regular file before it passes the data to the decryption path. This limits resource use and rejects unsuitable paths before an invalid file can affect the local vault.

This makes a backup portable without making it readable to the file system or provider. The backup carries its public key-derivation description so a fresh install can derive the vault key, but the database snapshot remains encrypted.

References: src-tauri/…/vault.rs• L200-262 src-tauri/…/pack.rs• L104-189 src-tauri/…/setup.rs• L240-265 src-tauri/…/storage.rs• L561-639

Entry import

A .swftx file is an independently encrypted entry transfer. The source password opens the file, each entry is merged by ID into the currently unlocked vault, and each payload is sealed again under the current vault key. The source and destination passwords can differ because the transfer crosses a vault boundary.

The import returns a refreshed metadata list and reports progress for large files. It does not replace the whole destination vault. It adds or updates entries while preserving the destination's encryption boundary.

The detailed file, picker, migration, and recovery behavior is in Import, export, and backup.

References: src/…/vault.ts• L27-43 src-tauri/…/vault.rs• L128-197 src-tauri/…/vault.rs• L200-262 src-tauri/…/migrate.rs• L45-53

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the .rowel pack format, Drive file naming, desktop file association, backup export, and restore parsing aligned.
  • Keep entry metadata projections aligned across src/…/types.ts, store columns and migrations, record construction, merge ranking, and frontend metadata rendering.
  • Keep the vault ID contract aligned across encrypted vault identity, workspace registry records, Drive pack names, restore stamping, and remote-vault discovery.
  • Keep provider credentials tied to the active workspace path when changing workspace switching, restore, delete, or token refresh flows.
  • Keep sync status events, probe snapshots, sequence handling, and merge metadata updates consistent when changing sync state transitions.
  • Keep tombstone retention and purge behavior aligned with merge rules so a delete cannot silently turn into a later re-created entry.
  • Keep the separate SQLCipher, entry-payload, attachment, and provider-token key roles aligned when changing vault key derivation or legacy compatibility.

Important failure modes

TriggerConsequenceGuard
The key-derivation sidecar does not match the database or is missing from a current vaultThe vault cannot open, or a valid password can look invalidTreat the database, key descriptor, and recovery pair as one vault unit and write sidecars atomically
A remote pack is truncated, malformed, from another vault, or written by a newer buildRestore or sync stops before it changes the local vaultValidate the pack header and key descriptor, then open it in a temporary database
A sealed entry payload or attachment is moved under another row IDThe protected data fails to open instead of being shown with the wrong metadataBind each object to its row ID and reject an ID mismatch
A workspace switch starts while a sync or provider adoption is using the active pathsCredentials or a snapshot could be associated with the wrong workspaceRefuse the switch while sync flows are busy and bind adoption to the workspace and vault read before the network round trip
Another device deletes the vault everywhereA normal first-sync path could recreate the deleted remote packKeep a remote deletion marker and stop runs that find the marker without the pack
A device stays offline longer than tombstone retentionAn old local copy can reintroduce an entry whose delete marker was reclaimedKeep tombstones through the retention window and sync devices before they remain offline beyond it
Provider credentials are disconnected or cannot be refreshedThe local vault remains usable, but future remote sync and remote restore cannot runKeep sync configuration tied to the token file and report the provider error without treating the vault as deleted
An attachment is added to a legacy vaultThe file cannot use the current attachment encryption schemeRefuse attachment storage for legacy-keyed vaults rather than applying a second incompatible scheme

Key files

FileWhy to read it
src/…/types.tsDefines the boundary between entry metadata, protected entry data, workspace identity, and unlock results.
src/…/vault.tsShows how the unlocked session presents metadata, saves local changes, handles tombstones, and schedules sync.
src/…/app.tsShows session clearing, unlock entry loading, sync debounce, and frontend sync status ownership.
src-tauri/…/vault.rsDefines vault key separation, payload and attachment sealing, legacy compatibility, and entry binding.
src-tauri/…/storage.rsDefines the local vault boundary, sidecars, workspace paths, atomic writes, shared iOS storage, and bounded backup reads.
src-tauri/…/sqlite.rsShows encrypted database opening, metadata projections, merge behavior, tombstones, and snapshots.
src-tauri/…/vault.rsConnects reveal, save, archive, import, and backup actions to the native vault store.
src-tauri/…/workspace.rsDefines workspace identity, registry data, workspace paths, and remote-vault tracking.
src-tauri/…/layout.rsDefines the provider folder, pack names, extensions, and deletion markers.
src-tauri/…/pack.rsDefines the encrypted .rowel exchange format used by Drive and local backups.
src-tauri/…/engine.rsDefines the pull-merge-push model, deterministic convergence, race checks, and tombstone retention.
src-tauri/…/mod.rsConnects the sync engine to Google Drive, resolves vault IDs, and publishes remote workspace choices.
src-tauri/…/sync.rsDefines provider connection, run scheduling, status events, and single-run coordination.
src-tauri/…/setup.rsShows first-run consent, account probing, Drive restore, and fresh-vault adoption.