Skip to content

Agent runtime data volumes: declared data paths with snapshot/restore and portable export #1169

Description

@vybe

Summary

Agents accumulate runtime data — SQLite databases, large incremental files, working datasets — that cannot live in the git-synced template repo (it bloats fast and doesn't belong in version control), yet must survive container recreate, template re-pulls, and subscription auto-switch, and must move with the agent when it migrates to another Trinity instance.

Proposed model: agent = code (git) + credentials (.credentials.enc) + data (declared volume). Runtime data becomes a third declared artifact class, parallel to the existing credential pattern.

Context

Today the only options are committing data to the template repo (bloat, churn, merge conflicts) or leaving it in the container filesystem (lost on recreate — exactly the events that already destroy runtime state today: template re-pull, subscription auto-switch, image upgrade). Neither is acceptable for database-backed or data-heavy agents.

The platform already has the adjacent primitives:

  • .trinity/persistent-state.yaml (S4, Persistent state allowlist (S4) #383) — the "paths that survive reset" allowlist
  • Per-agent named volumes (agent-{name}-public, FILES-001; shared-folder volumes)
  • Backend-side Docker SDK file extraction (get_archive) that never mounts the agent workspace (src/backend/services/agent_shared_files_service.py)
  • The ~/.trinity/pre-check hook pattern for agent-side lifecycle hooks
  • Credential export/import as the portability surface

Design Sketch

  1. Declare — data_paths: section in template.yaml (or an extension of the S4 persistent-state allowlist) listing runtime-data paths, e.g. ~/data/, ~/db/agent.sqlite. Gitignored by convention.
  2. Mount — Trinity mounts declared paths from a named per-agent volume (agent-{name}-data), same pattern as agent-{name}-public. Survives recreate/re-pull/auto-switch.
  3. Durability — a backend snapshot job tars the volume on a schedule into the existing trinity-data bind mount (e.g. /data/agent-data-snapshots/) with retention. For SQLite, snapshot via a quiesce hook (~/.trinity/pre-snapshot, shebang-selected like pre-check) or sqlite3 .backup to avoid mid-write corruption.
  4. Portability — "move agent to another Trinity" = template URL + .credentials.enc + data snapshot tar. Extends the existing export/import surface.

Acceptance Criteria

  • template.yaml (or persistent-state allowlist) supports declaring runtime data paths
  • Declared paths are backed by a named per-agent volume that survives container recreate, template re-pull, and subscription auto-switch
  • Backend snapshot job with configurable schedule + retention; snapshots stored under the existing trinity-data bind mount
  • SQLite-safe snapshotting (quiesce hook or .backup-based copy), documented for template authors
  • Export/import flow covers the data volume alongside credentials (agent fully reconstructable on another instance without git carrying data)
  • Agent delete / rename cascades handle the data volume and snapshots (manual cascade per platform convention)
  • No new agent-side privileges: snapshot path is backend-side Docker SDK, agents stay off the platform network

Technical Notes

Related Work & Crosslinks

Building blocks (precedents this design reuses)

Interacting / gated work

Bug classes to design against

Documentation that must follow (tiered-docs rule: new capability)

  • docs/memory/requirements.md — new capability entry before implementation
  • docs/memory/architecture.md + a docs/memory/feature-flows/ slice
  • docs/agent-validation-spec.md (implemented by feat: Agent deployment compatibility validation — server-side checks with auto-fix offers #668) — new checks once data_paths exists, e.g.:
    • STATIC/HARD: every data_paths entry is excluded in .gitignore (the whole point is keeping it out of git)
    • STATIC/SOFT: data_paths entries don't overlap Trinity-managed paths (.trinity/, .claude/, .env) or git.commit_paths
    • STATIC/SOFT: data_paths present ⇒ replica-safety declaration consistent (not marked replica-safe)
    • STATIC/INFO: ~/.trinity/pre-snapshot (if present) is executable with a valid shebang — analog of A-004 for pre-check
  • docs/TRINITY_COMPATIBLE_AGENT_GUIDE.md — template-author documentation for data_paths + snapshot hooks

Activity

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

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions