systemprompt-sync 0.21.1

Cloud sync services for systemprompt.io AI governance infrastructure. File, database, and crate deployment across governance tenants in the MCP governance pipeline.
Documentation

Production infrastructure for AI agents

Website · Documentation · Guides · Core · Template · Discord


systemprompt-sync

Crates.io Docs.rs License: BSL-1.1 codecov

The bridge between the deployment you run locally and the one you run in the cloud, with your data moving on your terms in both directions. This crate pushes and pulls service files, database contexts, and access-control rules, and drives the full tenant deploy pipeline to Fly.io.

Layer: App, orchestrates domain modules. Part of the systemprompt-core workspace.

Overview

Bidirectional sync across five paths:

  • File sync uploads and downloads service configuration files (agents, skills, content, config) as gzipped tarballs.
  • Database sync exports and imports contexts between local and cloud Postgres.
  • Local sync reconciles content and access-control rules between disk and the local database.
  • Deploy sequences the full cloud deploy pipeline: pre-sync, build, Docker image, and Fly.io release.
  • Scheduled jobs run content and access-control sync in the background via the systemprompt scheduler.

Infrastructure · Self-Hosted Deployment

Modules

Module Purpose
SyncService Top-level orchestrator for file and database sync (lib.rs)
config SyncConfig / SyncConfigBuilder, configuration with builder semantics
api_client SyncApiClient, direct-sync versus cloud-relay endpoint selection, typed responses, retry with backoff
files FileSyncService tarball creation and push/pull; file_bundler/ assembles the archive
database DatabaseSyncService, round-trips context records between local and cloud Postgres
deploy DeployOrchestrator, the full tenant deploy pipeline (pre-sync, build, image, release)
crate_deploy CrateDeployService, release-artefact build and Docker deploy
diff ContentDiffCalculator, hash-based diff between disk and database content
local ContentLocalSync and AccessControlLocalSync, bidirectional disk/database sync
jobs ContentSyncJob and AccessControlSyncJob, scheduler-registered background jobs
models LocalSyncDirection, DiffStatus, diff items, and result types
error SyncError and SyncResult

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

[dependencies]
systemprompt-sync = "0.21"
use systemprompt_sync::{SyncConfig, SyncService, SyncDirection};

let config = SyncConfig::builder(
    "tenant-id",
    "https://api.systemprompt.io",
    "api-token",
    "./services",
)
.with_direction(SyncDirection::Push)
.with_dry_run(false)
.build();

let service = SyncService::new(config)?;
let results = service.sync_all().await?;

Error Handling

The crate uses SyncError for all error conditions. Representative variants:

  • MissingConfig - Required configuration (e.g., DATABASE_URL) not set
  • ApiError { status, message } - HTTP API failures with status code and message
  • Unauthorized - Authentication required
  • CommandFailed { command } - Shell command execution failure
  • PartialImport { completed, total, message } - Import failed after partial progress
  • TarballUnsafe - Rejected an unsafe tarball entry
  • Database - SQL / connection errors
  • Cloud / ConfigLoad / ExtensionDiscovery - Wrapped errors from the cloud, loader, and extension crates

Dependencies

Crate Purpose
systemprompt-cloud Cloud API client and tenant operations
systemprompt-database Database pool and provider traits
systemprompt-content Content repository and ingestion
systemprompt-security Access-control rule models
systemprompt-loader Config and extension discovery
systemprompt-extension Extension discovery
systemprompt-identifiers Typed identifiers (TenantId, ContextId, UserId, etc.)
systemprompt-models / systemprompt-traits / systemprompt-provider-contracts Domain types, trait interfaces, and provider registration

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.