Skip to content

fix(config): keep runtime state in HERMES_HOME/plugin-data/cronalytics - #11

Closed
HearthCore wants to merge 1 commit into
8bit64k:masterfrom
HearthCore:fix/runtime-state-plugin-data
Closed

HearthCore wants to merge 1 commit into
8bit64k:masterfrom
HearthCore:fix/runtime-state-plugin-data

Conversation

@HearthCore

Copy link
Copy Markdown

Description

Moves the plugin's runtime state (facts.db, watermark.json, pending.jsonl) out of the plugin code directory into Hermes' per-profile plugin data directory, ~/.hermes/plugin-data/cronalytics/ (the same location Hermes' own PluginState.data_dir uses). The base directory can be overridden with CRONALYTICS_DATA_DIR.

Why: Hermes hashes every file of a Python plugin member into its dependency stamp (pm/workspace.py::members_stamp). State written next to the code changed that stamp on every write, so each hermes start rebuilt a full dependency environment and snapshotted the live SQLite file into it (Hermes side: NousResearch/hermes-agent#122349).

  • cronalytics/config.py: new DATA_DIR; FACT_DB, WATERMARK_FILE, PENDING_FILE derive from it. All consumers already read these through config, so no other module changes.
  • One-time migration on import, under an flock: the existing DB is copied with the SQLite backup API (consistent even with a live -wal), the JSON files are copied, then every legacy file is moved to DATA_DIR/legacy-<timestamp>/ so the plugin directory holds code only. An existing DATA_DIR DB is never overwritten. Migration errors are logged and never block plugin load. Facts are derived from state.db, so anything a not-yet-restarted process writes meanwhile is recovered by the scanner.
  • Docs updated for the new paths (README, docs/, dev/, bundled skill reference), uninstall instructions now remove the data directory too, CHANGELOG entry under Unreleased.

Running in production on a Linux install with 8 profiles: after the change, pm.install.drift() stays {} across further cronalytics writes and hermes starts no longer rebuild; cronalytics health --json reports the full migrated history.

Fixes #10

Type of change

  • Bug fix (non-breaking change fixing an issue)
  • New feature (non-breaking change adding functionality)
  • Breaking change (fix or feature that would break existing behavior)
  • Documentation update
  • Chore (build, CI, tooling, cleanup)

Checklist

  • I have read CONTRIBUTING.md
  • Tests pass: python -m pytest tests/ -v --tb=short (155 passed, including 6 new in tests/test_config_migration.py: paths, env override, migration + move-aside, existing data wins / idempotent reload, partial legacy state)
  • Lint clean: ruff check .
  • Type check clean: mypy cronalytics/ dashboard/plugin_api.py (1 error, pre-existing and unchanged on master: dashboard/plugin_api.py:100 no-any-return)
  • Dashboard builds: cd dashboard && node build.js (not run: no dashboard changes in this PR)
  • Docs updated (if applicable): docs/ or dev/ files reflect the change
  • CHECKPOINT.md updated with decisions and verification notes (rebase will drop it) (no CHECKPOINT.md in the repo)
  • I am targeting master (or release/X.Y for hotfixes)

Hermes hashes every file of a Python plugin member into its dependency
stamp. facts.db, watermark.json and pending.jsonl written into the plugin
directory changed that stamp on every write, so each hermes start rebuilt
a full dependency environment (and snapshotted a live SQLite file).

State now lives in the per-profile plugin-data directory (override with
CRONALYTICS_DATA_DIR). Existing state is migrated once on load via the
SQLite backup API and the legacy files are moved to legacy-<ts>/.

Fixes #10
@HearthCore HearthCore closed this by deleting the head repository Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runtime state files are hard-coded into the plugin's own code directory

1 participant