Database & maintenance

Keep Forven's local store healthy — the automatic backup, prune, and checkpoint jobs, the retention windows you can tune, restoring a snapshot, reclaiming disk with VACUUM, market-data storage and trash, factory reset, and legacy home migration.

Forven keeps everything on your machine, in one place. The cost of that local-first design is that the store grows as the research loop works: backtests, activity rows, notifications, and heartbeats accumulate. Maintenance keeps that store fast and bounded without losing the data you care about — and mostly runs by itself.

This page is for operators. It covers the automatic jobs, the retention windows you can tune, database snapshots and how to restore one, reclaiming disk space, factory reset, and the one-time legacy home migration for returning users.

Where your data lives

All state lives under FORVEN_HOME, which defaults to ~/.forven. The pieces maintenance touches:

  • forven.db — the source of truth (SQLite). Strategies, trades, agent tasks, scheduler jobs, notifications, the activity log, and the key-value settings store all live here.
  • forven.db-wal and forven.db-shm — the write-ahead log and its index. SQLite runs in WAL mode for concurrency, so the live database is three files, not one.
  • forven_lab.db — the lab database.
  • workspace/ — markdown workspace files for the agents.
  • backups/database/ — the automatic snapshots (below).

Market data lives in a separate Parquet data lake, with its own trash and housekeeping — see market-data storage below.

The automatic jobs

Three scheduler jobs keep the store in shape:

JobWhenWhat it does
forven-db-backupDaily, 04:40Takes a consistent snapshot of the database.
forven-db-maintenanceDaily, 05:00Prunes rows past their retention window, checkpoints the WAL, and optionally VACUUMs.
forven-wal-checkpointEvery 30 minutesFlushes the write-ahead log back into the main file.

The two daily jobs are scheduled in the America/Halifax time zone out of the box; change a job's time or zone from the scheduler if you want them to run in your own quiet hours. Pruning runs in small batches (about 500 rows per transaction), so it never holds the write lock long enough to stall trading or scanning.

Without pruning, a few tables grow without bound — on busy installs the backtest results table has reached hundreds of megabytes and the activity log hundreds of thousands of rows. Your numbers depend on how hard you run the loop, but an untrimmed store gets slow.

Manual mode skips these jobs too

In Manual mode — the fresh-install default — the scheduler skips every scheduled job, these three included. A lab left in Manual takes no daily snapshot and prunes nothing until you switch to Semi or Auto. The pre-migration snapshot is not a scheduled job, so it still happens on startup.

Retention windows

DataSettingDefault
Trashed backtest resultsretention_backtest_trash_days14 days
Activity logretention_activity_log_days90 days
Agent heartbeatsretention_heartbeat_days2 days
Scanner resultsretention_scanner_results_days30 days
Gate rejectionsretention_gate_rejections_days30 days
Notificationsretention_notifications_days60 days
Agent transcripts and tool-call auditretention_agent_transcript_days45 days
Funding and open-interest historyretention_market_data_history_days900 days (never less than 760)
Strategy stage eventsretention_strategy_events_days365 days

Set a window to 0 to stop pruning that table. The funding-history floor exists because the data collectors re-download two years of funding history: a shorter window would just delete rows the next collection fetches again.

If you are investigating an event from more than 60 days ago, its notifications may already be pruned, and heartbeats older than two days are almost certainly gone. Keep your own copies if you need a longer audit trail.

Tuning them

Settings → System → Database maintenance shows four of the windows — Backtest trash retention, Activity log retention, Scanner results retention and Gate rejections retention — and the Daily VACUUM switch. All the windows are stored with the pipeline settings, so you can set any of them over the API:

# Read the current pipeline settings (includes the retention_* windows)
curl.exe http://127.0.0.1:8003/api/settings/pipeline

# Change a window (send x-operator-key if FORVEN_OPERATOR_KEY is set)
curl.exe -X PUT http://127.0.0.1:8003/api/settings/pipeline `
  -H "Content-Type: application/json" `
  -d '{ \"retention_activity_log_days\": 120 }'

The next maintenance run uses the new windows. Longer windows keep more history at the cost of disk and query speed.

Backups

Snapshots are written to FORVEN_HOME/backups/database as forven-<reason>-<timestamp>.db — a daily one from the backup job and a pre-migration one before any schema migration runs. Each snapshot is a consistent single-file copy, safe to take while Forven is running.

Retention is per reason: the last 7 daily snapshots and the last 3 pre-migration ones (3 for anything else). A size ceiling bounds the whole folder — the larger of 2 GiB or six times the database size — and a snapshot is refused outright if writing it would leave the disk dangerously full. Both are adjustable with environment variables.

Steps: restore a snapshot

  1. Stop Forven — close it from the launcher, or stop start_all.
  2. Keep the current database aside: rename forven.db to something like forven.db.broken, and move forven.db-wal and forven.db-shm out of the folder with it.
  3. Copy the snapshot you want from backups/database to FORVEN_HOME and rename it forven.db.
  4. Start Forven. Any migrations the snapshot predates run again on startup.

What you'll see: the app comes back in the state of the snapshot — strategies, trades, and settings as they were at that time. Anything that happened after it is gone, which is why step 2 keeps the old file.

A copy of forven.db alone, taken by hand while Forven is running, is not a complete backup — the latest writes may still be in the WAL. Use the snapshots, or stop Forven before copying.

Reclaiming disk with VACUUM

Pruning frees space inside the database file, which SQLite reuses, but it doesn't shrink the file on disk. VACUUM rewrites the file compactly. It takes an exclusive lock and can take a while on a large database, blocking every other writer until it finishes — which is why it is off by default.

  • Automatic: turn on Daily VACUUM in Settings → System → Database maintenance, and the daily maintenance job runs it after a prune.
  • By hand: stop Forven first, then run it with the app closed:
python -c "import sqlite3; c = sqlite3.connect(r'C:\Users\you\.forven\forven.db'); c.execute('VACUUM'); c.close()"

What you'll see: forven.db shrinks to roughly the size of its live data.

Stopping Forven stops paper trading until you start it again, and does not close any open positions. On a paper install that is harmless. If you have wired up unsupported live trading, exit positions deliberately before any disruptive maintenance.

Market-data storage

The candle lake and the enrichment streams have their own housekeeping, on Data → Storage:

Tile or sectionWhat it shows
LakeTotal size, series and files, and the data folder's path.
Disk freeFree space on the data drive. Downloads refuse to start below the free-disk floor (jobs stop below 5 GB free).
Size by stream · Largest seriesWhere the space goes. The revision log line says how much history is older than the prune age.
Reclaimable spaceGroups of files you can clear, each tagged Safe or Review first. Show items lists them; Move to trash (or Prune for the revision log) asks you to type the phrase it shows, such as reclaim revisions.
TrashEverything deleted or reclaimed, restorable with Restore until it is purged automatically. Empty now deletes it all for good, after you type empty trash and click Delete for good.
Identity auditA report of naming problems — the same instrument under two names, unknown symbols, stray folders, series with no provenance stamp — each with a suggestion. It never moves anything.

Reclaiming moves files to the trash first; nothing is deleted until the trash is emptied or the retention runs out. Deleting a series from the Catalog shows which strategies use it and asks for a typed confirmation, and the series goes to the same trash.

The defaults live in Settings → Data → Storage:

SettingDefaultMeaning
Trash retention7 daysHow long deleted series and reclaimed files stay restorable.
Free-disk floor5 GBDownloads refuse to start when free disk under the data folder is below this.
Revision log prune age180 daysThe default cut-off for pruning the revision log on the Storage view. Restatements inside a saved verdict's window are always kept.

Factory reset

When you want to clear data rather than prune it, Settings → Danger Zone → Factory reset wipes selected categories. You tick the categories to keep, click Wipe & factory reset…, then type FACTORY RESET and click Wipe everything:

CategoryWhat it clears
Pipeline & StrategiesEvery strategy, stage transition, archived strategy, and approval.
Agent Tasks & AuditAgent task history and tool-call audit logs.
Trade HistoryTrade records and the audits attached to them.
Activity LogSystem activity and event logs.
AI MemoryThe agents' workspace memory files.
Scheduler StateJob timers and error state (the jobs themselves are kept).
SettingsAll configuration.
Workspace DocumentsAgent identity, operator profile, and agent and tool docs.
API Keys & CredentialsExchange keys, model-provider tokens, and auth credentials. Kept unless you explicitly opt in to wiping them.

Factory reset is destructive and operator-gated (POST /api/system/factory-reset; GET /api/system/factory-reset/categories lists the catalog). Treat it as a last resort, and make sure you have a recent snapshot first.

Legacy home migration

Earlier builds stored state under ~/.juddex or ~/.judex. On first startup Forven detects those directories and merges them into ~/.forven, renaming the database files (juddex.db → forven.db). Returning users keep their history with no manual steps.

  • Workspace writes are mirrored back to the legacy workspace/ folder for compatibility. Where the two copies of a file have diverged, the longer one wins — check a backup if a workspace file looks wrong after migration.
  • The encryption key lives outside FORVEN_HOME (%LOCALAPPDATA%\Forven\.forven_key on Windows), while the encrypted auth.json lives inside it. Back them up together, or encrypted credentials can stop decrypting. See encryption & secrets.

Caveats

  • The live database is three files. Use the snapshots, or stop Forven before copying forven.db by hand.
  • Notifications and heartbeats are short-lived. Their 60-day and 2-day windows mean old audit rows disappear.
  • VACUUM is exclusive. Run it only while the app is quiet, or stopped.
  • Maintenance never touches positions. Pruning and snapshots operate only on local records.
  • The encryption key doesn't live with your data. Back it up with FORVEN_HOME.

Forven is a research tool. Nothing here is financial advice, results are not predictive, and maintenance routines operate only on local records — they do not affect any exchange position.