Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Wassette needs state persistence to enable agent handoffs, backups, and environment migrations. This adds JSON-based snapshot export/import with security-first design.

Implementation

Core module (state_persistence.rs)

  • StateSnapshot with versioned JSON schema
  • ComponentState captures metadata, policies, optional binaries (base64)
  • Validation and file I/O operations

LifecycleManager methods

  • export_state(options) → captures runtime state
  • import_state(snapshot, options) → restores from snapshot
  • Component filtering, metadata tagging, skip-existing mode

Security model

  • Secrets excluded (never serialized)
  • Policies included (auditable, not sensitive)
  • Unix 0600 permissions on restored files
  • Structure validation before import

API

// Export state (default: ~1KB/component, no binaries)
let snapshot = manager.export_state(SnapshotOptions {
    include_binaries: false,  // true for self-contained (~1-10MB/component)
    component_filter: Some(vec!["fetch-rs".into()]),  // or None for all
    metadata: Some(SnapshotMetadata { 
        description: Some("prod backup".into()),
        tags: Some(HashMap::from([("env", "prod")])),
        ..Default::default()
    }),
    ..Default::default()
}).await?;

snapshot.save_to_file("state.json").await?;

// Import state
let snapshot = StateSnapshot::load_from_file("state.json").await?;
let count = manager.import_state(&snapshot, RestoreOptions {
    skip_existing: true,
    ..Default::default()
}).await?;

Use cases

  • Agent handoff: Transfer Copilot → Claude Code with preserved configuration
  • Backup/restore: Regular snapshots for disaster recovery
  • Environment promotion: Dev → staging → prod with consistent state
  • Team collaboration: Share configs via git (small snapshots without binaries)
  • CI/CD: Reproducible test environments from fixture snapshots

Related

Complements headless deployment (#307): manifest provisioning for initial setup, state snapshots for runtime transfer.

Files

  • crates/wassette/src/state_persistence.rs - New module
  • crates/wassette/src/lib.rs - Export/import methods
  • crates/wassette/src/policy_internal.rs - PolicyInfo serialization
  • docs/design/state-persistence.md - Architecture and security analysis
  • docs/examples/state-persistence-examples.md - Usage patterns

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/Mossaka/wit-docs-inject/commits/HEAD
    • Triggering command: /home/REDACTED/.rustup/toolchains/1.90-x86_64-REDACTED-linux-gnu/bin/cargo install --git REDACTED (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Explore how to save the state of wassette for transfer between agents</issue_title>
<issue_description>Investigate methods to persist the state of wassette so that it can be transferred or shared between different agents. Consider use cases, possible data formats, and potential security or consistency considerations.

Related: #307</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Explore methods to save wassette state for agent transfer Add state persistence for wassette runtime transfer between agents Nov 12, 2025
Copilot AI requested a review from Mossaka November 12, 2025 20:49
@Mossaka Mossaka marked this pull request as ready for review November 12, 2025 21:03
Copilot AI and others added 2 commits November 13, 2025 23:07
- Created state_persistence.rs module with StateSnapshot structure
- Added export_state() and import_state() methods to LifecycleManager
- Implemented serialization for component state, policies, and metadata
- Added support for optional binary data inclusion in snapshots
- Implemented validation and file I/O operations
- Added comprehensive unit tests (all passing)
- Fixed PolicyInfo serialization with custom SystemTime serde

Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
- Created design document covering architecture, use cases, security
- Added examples documentation with code snippets
- Created investigation summary for Issue #309
- Documented API design, performance analysis, and best practices
- Included comparison with alternatives and integration with headless mode

Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
@Mossaka Mossaka force-pushed the copilot/explore-wassette-state-saving branch from bc68432 to 60db272 Compare November 14, 2025 04:07
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.

Explore how to save the state of wassette for transfer between agents

2 participants