Skip to content

Persistent state allowlist (S4) #383

Closed

Description

@vybe

Summary

Add a persistent_state allowlist to each agent's config so template-level resets preserve instance-specific files.

Context

Problem P3: To recover from parallel-history deadlock (P2), operators must SSH into the agent and manually run git reset + file restoration. There's no first-class API for "reset to main, but keep my workspace data."

Key insight: template.yaml is only read at agent creation (services/template_service.py:177-200). Sync and reset paths don't re-read it. The allowlist must be materialized to .trinity/persistent-state.yaml at creation time.

Acceptance Criteria

  • Template provides default persistent_state list in template.yaml
  • At agent creation, write .trinity/persistent-state.yaml to container
  • Sync/reset operations read from .trinity/persistent-state.yaml
  • Operators can edit the file directly to adjust per-agent

Default allowlist

persistent_state:
  - workspace/**
  - .trinity/**
  - memory/**
  - .mcp.json
  - .claude.json

Backend implementation

  • Add _persistent_state_for(agent_name) -> list[str] helper to git_service.py
  • Read from .trinity/persistent-state.yaml, fall back to sensible default

Agent-server implementation

  • New subroutine _reset_preserving_persistent_state(target_ref):
    • Capture matching files to tmp dir
    • Run git reset --hard <target>
    • Overlay files back
    • Commit "Adopt baseline, preserve state"

Agent creation

  • services/agent_service/crud.py writes .trinity/persistent-state.yaml from template's persistent_state key

Technical Notes

Files to modify:

  • src/backend/services/git_service.py — new helper
  • docker/base-image/agent_server/routers/git.py — reset subroutine
  • src/backend/services/agent_service/crud.py — write file on creation

This is the keystone for S3 (reset-preserve-state operation).

Part of Epic #381

Activity

  1. added
    priority-p1
    type-feature
    on Apr 18, 2026
  2. added
    complexity-medium
    theme-reliability
    on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p1theme-reliabilitytype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions