Skip to content

refactor(settings): replace vault with SQLite MVCC versioning (#1297)#1302

Open
crrow wants to merge 7 commits intomainfrom
issue-1297-settings-mvcc
Open

refactor(settings): replace vault with SQLite MVCC versioning (#1297)#1302
crrow wants to merge 7 commits intomainfrom
issue-1297-settings-mvcc

Conversation

@crrow
Copy link
Copy Markdown
Collaborator

@crrow crrow commented Apr 12, 2026

Summary

  • Remove unused rara-vault crate (1,260 lines deleted, zero dependents)
  • Add MVCC append-only settings_version table as sole settings storage
  • Rewrite SettingsSvc to read/write settings_version exclusively (drops KVStore dependency)
  • Add HTTP API: GET /versions, GET /versions/current, GET /versions/{n}, POST /versions/{n}/rollback
  • Extend agent SettingsTool with version, history, snapshot, rollback actions

Type of change

Type Label
Refactor refactor

Component

core, backend

Closes

Closes #1297

Test plan

  • 7 unit tests for MVCC: set_bumps_version, get_returns_latest_value, snapshot_at_version, delete_creates_tombstone, batch_update_single_version, list_returns_current_snapshot, rollback_creates_new_version
  • cargo check --workspace passes
  • cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings passes
  • cargo +nightly fmt --all -- --check passes

github-actions bot and others added 4 commits April 12, 2026 22:07
Remove rara-vault crate, its workspace references, and the old vault
design doc. The crate was never imported by any other crate.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…1297)

Extend SettingsTool with MVCC-aware actions so mita can inspect version
history and rollback settings. The tool now holds Arc<SettingsSvc> directly
instead of Arc<dyn SettingsProvider>.

New actions:
- version: returns current global version number
- history: returns the last 20 version log entries
- snapshot: returns settings at a given version (key = version number)
- rollback: reverts to a given version (forward operation, creates new version)

Closes #1297

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rewrite backend-admin AGENT.md to document MVCC append-only versioning,
  SettingsSvc public API, and forward-only rollback semantics
- Remove vault from harness-engineering.md layer map
- Remove rara-vault from devtool check-deps layer config

Closes #1297
@crrow crrow added refactor Code refactoring core Core system changes labels Apr 12, 2026
…se structs (#1297)

- SettingsAction enum replaces string-matched action field
- Typed SnapshotResponse/RollbackResponse/VersionResponse replace json! macros
- Dedicated `version` param field instead of overloading `key`
- Extract MASK_VISIBLE_LEN, DEFAULT_VERSION_LIMIT, TOOL_HISTORY_LIMIT constants
- Remove redundant .map_err(anyhow) on already-anyhow Results
- P0: wrap version bump + log append in a single SQLite transaction
  to prevent race conditions between concurrent writes
- P1: use axum .nest() for version routes to avoid wildcard collision
- P1: validate target_version range in rollback_to() to prevent
  accidental data deletion on non-existent version
- P2: fix list_versions to limit by distinct version count, not row count
- P2: log warning instead of silently falling back when list() fails
- P2: replace unwrap() with expect() in batch_update
- P3: update module doc from "Flat KV" to "MVCC-versioned"
- P3: strip settings. prefix from VersionEntry keys for API consistency
- P3: use char-based masking in maybe_mask to prevent UTF-8 panics

Closes #1297
- P1: validate version range in snapshot() — reject future/negative
  versions instead of silently returning latest snapshot
- P1: mask sensitive values in tool History and Snapshot actions —
  previously bypassed maybe_mask, leaking full secrets to agents
- P2: decode JSON-encoded string values in list_versions() — return
  plain strings consistent with get/list/snapshot APIs
- Return 404 (not 500) from snapshot/rollback HTTP endpoints when
  the requested version does not exist

Closes #1297
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Core system changes refactor Code refactoring

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

refactor(settings): replace vault with SQLite MVCC versioning

1 participant