Production infrastructure for AI agents
Website · Documentation · Guides · Core · Template · Discord
systemprompt-sync
Cloud sync services for systemprompt.io AI governance infrastructure. Provides file, database, and crate deployment synchronization across governance tenants — bidirectional sync between local and cloud environments.
Layer: App — orchestrates domain modules. Part of the systemprompt-core workspace.
Overview
Part of the App layer in the systemprompt.io architecture. Infrastructure · Self-Hosted Deployment
This crate provides bidirectional sync capabilities for:
- File Sync - Upload/download service configuration files (agents, skills, content, config) as gzipped tarballs
- Database Sync - Export/import contexts between local and cloud Postgres databases
- Local Sync - Synchronise content and access-control rules between disk and the local database
- Crate Deploy - Build and deploy Docker images to Fly.io
- Scheduled Jobs - Background sync jobs registered with the systemprompt scheduler
Architecture
src/
├── lib.rs # Crate root, SyncService, SyncConfig, SyncOpState, public exports
├── error.rs # SyncError enum and SyncResult alias
├── files.rs # FileSyncService - tarball creation, manifest, push/pull
├── file_bundler.rs # Internal tarball assembly helper (private)
├── crate_deploy.rs # CrateDeployService - Docker build and deploy
├── api_client/
│ ├── mod.rs # SyncApiClient - direct-sync vs cloud-relay endpoint selection
│ ├── response.rs # Typed JSON / binary response handling
│ └── retry.rs # RetryConfig and exponential backoff
├── database/
│ ├── mod.rs # DatabaseSyncService, ContextExport, DatabaseExport
│ └── upsert.rs # Compile-time-checked context upserts
├── diff/
│ ├── mod.rs # Diff module exports, compute_content_hash
│ └── content.rs # ContentDiffCalculator - disk vs database content
├── export/
│ ├── mod.rs # Export utilities, escape_yaml
│ └── content.rs # Content markdown generation and file export
├── local/
│ ├── mod.rs # Local sync drivers
│ ├── content_sync.rs # ContentLocalSync - bidirectional content sync
│ └── access_control_sync.rs # AccessControlLocalSync - bidirectional ACL sync
├── jobs/
│ ├── mod.rs # Scheduled jobs
│ ├── content_sync.rs # ContentSyncJob
│ └── access_control_sync.rs # AccessControlSyncJob
└── models/
├── mod.rs # Model exports
└── local_sync.rs # LocalSyncDirection, DiffStatus, diff items, result types
Module Details
| Module | Purpose |
|---|---|
SyncService |
Top-level orchestrator for file and database sync operations |
SyncConfig / SyncConfigBuilder |
Configuration façade with builder semantics |
SyncApiClient |
HTTP client with direct-sync and cloud-relay endpoints |
FileSyncService |
Creates and extracts gzipped tarballs for file sync |
DatabaseSyncService |
Round-trips context records between local and cloud Postgres |
CrateDeployService |
Builds release artefacts, Docker image, and deploys to Fly.io |
ContentDiffCalculator |
Hash-based diff between disk and database content |
ContentLocalSync |
Syncs content to and from disk via ingestion services |
AccessControlLocalSync |
Syncs access-control rules to and from disk |
ContentSyncJob / AccessControlSyncJob |
Scheduler-registered background jobs |
Sync Directions
| Direction | Description |
|---|---|
Push |
Local to cloud (upload files, push database) |
Pull |
Cloud to local (download files, pull database) |
Local disk-database sync uses LocalSyncDirection (ToDisk, ToDatabase) on LocalSyncResult.
Operation State
SyncService::sync_all returns per-operation results with a SyncOpState:
| State | Meaning |
|---|---|
NotStarted |
Operation was skipped (e.g. missing local database URL) |
Partial { completed, total } |
Operation imported a subset of items before failing |
Completed |
Operation finished successfully |
Failed |
Operation failed without partial progress |
Usage
[]
= "0.11.0"
use ;
let config = builder
.with_direction
.with_dry_run
.build;
let service = new;
let results = service.sync_all.await?;
Error Handling
The crate uses SyncError for all error conditions:
MissingConfig- Required configuration (e.g.,DATABASE_URL) not setApiError- HTTP API failures with status code and messageDatabase- SQL/connection errorsIo- File system errorsUnauthorized- Authentication requiredCommandFailed- Shell command execution failures
Dependencies
| Crate | Purpose |
|---|---|
systemprompt-database |
Database pool and provider traits |
systemprompt-content |
Content repository and ingestion |
systemprompt-agent |
Agent and access-control repositories |
systemprompt-security |
Access-control rule models |
systemprompt-identifiers |
Typed identifiers (TenantId, ContextId, UserId, etc.) |
systemprompt-logging |
Tracing integration |
License
BSL-1.1 (Business Source License). Source-available for evaluation, testing, and non-production use. Production use requires a commercial license. Each version converts to Apache 2.0 four years after publication. See LICENSE.
systemprompt.io · Documentation · Guides · Live Demo · Template · crates.io · docs.rs · Discord
App layer · Own how your organization uses AI.