DATASTORE CONFIGURATION
The datastore controls where Swamp stores runtime data — evaluated definitions,
workflow runs, and data outputs. By default, everything lives in .swamp/
within the repository. Audit logs, the telemetry spool, and run logs always stay
in the checkout's own .swamp/, whichever datastore is configured. An external
filesystem path or an extension-provided backend (such as S3) can replace the
default location. Vault secrets (.swamp/secrets/) are stored separately and
are never included in datastore sync — see the
vaults reference.
datastore:
type: filesystem
path: /data/swamp-storeBackend Types
filesystem
Stores data at a directory on the local filesystem.
| Property | Value |
|---|---|
| Type identifier | filesystem |
| Built-in | Yes |
| Sync support | No |
| Lock implementation | File-based (atomic create) |
When no datastore field is present in .swamp.yaml, Swamp uses the filesystem
backend with path set to {repoDir}/.swamp/.
Extension backends
Extension-provided datastores use a scoped type identifier in @collective/name
format (e.g., @swamp/s3-datastore). Extensions implement the
Datastore Provider interface
and are loaded from extensions/datastores/ within the repository.
| Property | Value |
|---|---|
| Type identifier | @collective/name |
| Built-in | No |
| Sync support | Optional (extension-defined) |
| Lock implementation | Extension-defined |
| Authentication | Requires swamp auth login or SWAMP_API_KEY with datastore:* scope |
The legacy type s3 is automatically remapped to @swamp/s3-datastore.
@swamp/s3-datastore
First-party extension that stores data in an Amazon S3 bucket with local cache
synchronization. Distributed locking uses S3 conditional writes
(If-None-Match: *). Bidirectional sync transfers files between a local cache
directory and S3.
datastore:
type: "@swamp/s3-datastore"
config:
bucket: my-swamp-bucket
prefix: project-name
region: us-east-1Config fields
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
bucket |
string | Yes | — | S3 bucket name |
prefix |
string | No | None | Key prefix within the bucket |
region |
string | No | None | AWS region (e.g., us-east-1) |
endpoint |
string | No | None | Custom S3-compatible endpoint URL (MinIO, DigitalOcean Spaces) |
forcePathStyle |
boolean | No | false |
Force path-style S3 URLs instead of virtual-hosted-style |
Authentication
Uses the default AWS credential chain — no credentials in the config object. Provide credentials via one of:
- Environment variables:
AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY - AWS profile:
~/.aws/credentials - SSO profile in
~/.aws/config, selected withAWS_PROFILE - IAM role attached to the instance or task
AWS_CONFIG_FILE overrides the config file path. Refer to
Authenticate to AWS with SSO for
the sign-in sequence and session-expiry messages.
On a plain EC2 instance, the instance metadata credential lookup is disabled
unless AWS_CONTAINER_CREDENTIALS_RELATIVE_URI,
AWS_CONTAINER_CREDENTIALS_FULL_URI, or AWS_EC2_METADATA_DISABLED is set. Set
AWS_EC2_METADATA_DISABLED=false to use an attached instance profile.
Required IAM permissions
s3:HeadBuckets3:GetObjects3:PutObjects3:DeleteObjects3:ListBuckets3:HeadObject
Setup
$ swamp datastore setup extension @swamp/s3-datastore \
--config '{"bucket":"my-bucket","region":"us-east-1"}'With a key prefix and custom endpoint:
$ swamp datastore setup extension @swamp/s3-datastore \
--config '{"bucket":"my-bucket","prefix":"swamp","endpoint":"https://minio.internal:9000","forcePathStyle":true}'Environment variable
SWAMP_DATASTORE=@swamp/s3-datastore:{"bucket":"my-bucket","region":"us-east-1"}The legacy format SWAMP_DATASTORE=s3:my-bucket/prefix is also accepted and
auto-remapped. The part before the first / is the bucket; the rest is the
prefix.
Sync
The S3 backend supports bidirectional sync via swamp datastore sync. Write
commands automatically pull before executing and push after. Change detection
compares file size and modification time against a remote index. Transfers run
with a concurrency of 10.
The local cache lives at ~/.swamp/repos/{repoId}/ by default.
S3-compatible services
The endpoint and forcePathStyle fields enable use with S3-compatible
services such as MinIO, DigitalOcean Spaces, Backblaze B2, and Cloudflare R2.
Set forcePathStyle: true when the service does not support
virtual-hosted-style bucket addressing.
@swamp/gcs-datastore
First-party extension that stores data in a Google Cloud Storage bucket. Distributed locking uses GCS generation-based preconditions. Bidirectional sync works the same way as the S3 extension.
datastore:
type: "@swamp/gcs-datastore"
config:
bucket: my-gcs-bucket
prefix: swamp| Field | Type | Required | Description |
|---|---|---|---|
bucket |
string | Yes | GCS bucket name |
prefix |
string | No | Key prefix within the bucket |
projectId |
string | No | GCP project ID (defaults to the project from Application Default Credentials) |
apiEndpoint |
string | No | Custom API endpoint URL (for emulators like fake-gcs-server; skips auth) |
Authentication uses Google Cloud Application Default Credentials (ADC):
- Environment variable:
GOOGLE_APPLICATION_CREDENTIALSpointing to a service account key JSON file - User credentials:
gcloud auth application-default login - Attached service account on GCE, Cloud Run, or GKE
Required IAM permissions (covered by the roles/storage.objectAdmin predefined
role):
storage.buckets.getstorage.objects.createstorage.objects.getstorage.objects.deletestorage.objects.list
Configuration Fields
The datastore field in .swamp.yaml accepts the following properties.
type
Backend type identifier.
| Property | Value |
|---|---|
| Type | string |
| Required | Yes (within datastore) |
| Values | filesystem, or an extension type (@collective/name) |
path
Absolute path for the filesystem datastore directory.
| Property | Value |
|---|---|
| Type | string (absolute path) |
| Required | No |
| Default | {repoDir}/.swamp/ |
| Applies | filesystem type only |
config
Arbitrary key-value configuration passed to extension-provided datastores. The
extension's configSchema (if defined) validates this object at setup time.
String values in config support
expression interpolation.
| Property | Value |
|---|---|
| Type | Record<string, unknown> |
| Required | No |
| Applies | Extension types only |
datastore:
type: "@swamp/s3-datastore"
config:
bucket: my-swamp-bucket
prefix: project-name
region: us-east-1hydrationStrategy
Content download strategy for extension-provided datastores with sync support.
| Property | Value |
|---|---|
| Type | string |
| Required | No |
| Default | "full" |
| Values | "full", "lazy" |
| Applies | Extension types with sync only |
When set to "full", the initial sync downloads all files from the remote
backend. When set to "lazy", the initial sync downloads only metadata files
(metadata.yaml, latest markers, partition indexes) and skips content files
(raw) under data/. Content files are downloaded on demand when first
accessed.
Lazy hydration requires the extension to advertise lazyHydration in its
SyncCapabilities and implement the hydrateFile method on its sync service.
See the Datastore Provider
reference.
datastore:
type: "@swamp/s3-datastore"
hydrationStrategy: lazy
config:
bucket: my-bucket
region: us-east-1directories
Which .swamp/ subdirectories are stored in the datastore. When omitted, all
default subdirectories are included.
| Property | Value |
|---|---|
| Type | string[] |
| Required | No |
| Default | All default subdirectories (see below) |
Default subdirectories:
definitions-evaluated workflows-evaluated data
outputs workflow-runs audit
telemetry logs filesVault secrets (.swamp/secrets/) are excluded from this set — they always
remain local to the machine regardless of datastore backend. See the
vaults reference
for details.
datastore:
type: filesystem
path: /data/swamp-store
directories:
- data
- outputs
- workflow-runsSubdirectories not in this list remain in the local .swamp/ directory.
managedConfig
Opt-in flag that stores configuration in the datastore tier.
| Property | Value |
|---|---|
| Type | boolean |
| Required | No |
| Default | false |
| Applies | Extension types with sync support only |
When true, behavior definitions, workflow definitions, vault configs, the
extension lockfile, and pulled extension sources are stored in a config
subdirectory within the datastore. The datastore becomes the single source of
truth for configuration across swamp serve instances.
Set automatically by swamp datastore config migrate. Can also be set manually:
datastore:
type: "@swamp/s3-datastore"
managedConfig: true
config:
bucket: my-bucket
region: us-east-1Requires the datastore extension to support the configRefresh sync capability
(see Config Refresh Capability). Without
configRefresh, other instances cannot poll for config changes and
managedConfig has no effect.
See Enable Managed Config for the step-by-step setup guide.
exclude
Gitignore-style patterns for files to exclude from datastore operations.
| Property | Value |
|---|---|
| Type | string[] |
| Required | No |
datastore:
type: filesystem
path: /data/swamp-store
exclude:
- "telemetry/**"namespace
Namespace identifier for this repository within a shared datastore. When set,
data is scoped under .swamp/<namespace>/ instead of .swamp/ directly.
| Property | Value |
|---|---|
| Type | string |
| Required | No |
| Default | None (solo mode — data at top level) |
| Format | Lowercase slug (e.g., infra, compute, security) |
datastore:
type: "@swamp/s3-datastore"
namespace: infra
config:
bucket: shared-bucket
region: us-east-1For new shared datastores, set the namespace during setup with
swamp datastore setup extension --namespace <slug> — this assigns the
namespace and migrates data in one step. For existing solo repositories
transitioning to a namespace, use swamp datastore namespace set <slug>
followed by swamp datastore namespace migrate --yes. See the
Namespace Commands section below.
durable
Syncs each data version to disk before it is published.
| Property | Value |
|---|---|
| Type | boolean |
| Required | No |
| Default | false |
| Env var | SWAMP_DATASTORE_DURABLE, used when the datastore block does not set it |
| Applies | filesystem type, and the local cache of a v2 extension datastore |
datastore:
type: filesystem
path: /data/swamp-store
durable: trueThe setting resolves in this order:
| Priority | Source |
|---|---|
| 1 | durable in the datastore block |
| 2 | SWAMP_DATASTORE_DURABLE environment variable |
| 3 | Off |
SWAMP_DATASTORE_DURABLE accepts 1, true, yes or on to turn durable
writes on, and 0, false, no or off to turn them off, in any case. Any
other value is ignored.
A durable value that is not a boolean is refused when the configuration is
read:
Error: Invalid 'durable' in the datastore block of .swamp.yaml: expected true or false, got "yes".swamp datastore setup keeps the setting when it is run again.
What each setting guarantees
| Setting | Guarantee |
|---|---|
| Off | Each write is atomic and survives a process crash. Nothing is synced, so a power cut can lose a write, or publish a version whose content is empty (on ext4, delayed allocation can keep the rename, the latest marker and the catalog row but lose the bytes). |
| On | A version's content (metadata.yaml and raw) and the directory entries that reach it are on disk before the latest marker moves to it and its catalog row is written. A file whose bytes are streamed to a data writer is synced the same way. |
On a v3 datastore, committed versions are already durable: the commit is durable
and replay rewrites the checkout. A v3 version that the checkout's
directories or exclude keep local is never
committed, so it is synced as on v2.
Cost
Each durable write costs several fsyncs: roughly double the write time on a local NVMe disk, and more on network or spinning disks.
On macOS, the default datastore (.swamp/data, with no custom path and no
namespace) orders its writes with F_BARRIERFSYNC instead of flushing the
drive cache with F_FULLFSYNC. The newest versions may not survive a power cut,
but a version is never published without its content. A workflow run writing 804
data versions on an Apple silicon Mac took about 36 s with full syncs and about
21 s ordered, against 18 s with durable writes off.
These keep the full drive-cache flush on macOS:
- a filesystem datastore with a custom
path - a namespaced datastore
- an extension datastore's local cache
- a v3 datastore
swamp data delete,rename,pruneandgc, andswamp behavior delete
Set a custom path where the newest versions must survive a power cut on macOS.
Sync failures
A sync that fails fails the write before anything publishes the version:
Could not sync <path> to disk: <reason>.EIO or ENOSPC as the reason indicates a disk problem. A filesystem that
cannot sync files at all adds a hint to the message:
This filesystem cannot sync files to disk; set `durable: false` on the datastore in .swamp.yaml to write data without syncing it.Legacy S3 shorthand fields
These fields are accepted in .swamp.yaml for backwards compatibility with the
legacy s3 type. They are equivalent to placing the values inside config for
the @swamp/s3-datastore extension.
| Field | Type | Description |
|---|---|---|
bucket |
string | S3 bucket name |
prefix |
string | Key prefix within the bucket |
region |
string | AWS region |
endpoint |
string (URL) | Custom S3-compatible endpoint URL |
forcePathStyle |
boolean | Force path-style S3 URLs (default false) |
Expression Interpolation in Configuration Values
String values in the following fields support expression interpolation using the
${{ }} delimiter syntax. Expressions are resolved during config resolution,
before schema validation and createProvider().
| Field | Scope |
|---|---|
datastore.config.* |
All string values in the datastore config |
datastore.namespace |
The datastore namespace |
datastore.directories |
Each array element |
datastore.exclude |
Each array element |
datastore.hydrationStrategy |
The hydration strategy value |
repoId |
Top-level repo identifier (UUID validated after resolution) |
swampVersion |
Top-level swamp version constraint |
Two expression namespaces are supported.
env
Resolves to the value of the named environment variable. Throws a startup error if the variable is not set or empty.
datastore:
type: "@swamp/s3-datastore"
config:
bucket: "${{ env.SWAMP_S3_BUCKET }}"
region: "${{ env.AWS_REGION }}"
endpoint: "https://${{ env.S3_HOST }}:9000"Expressions can appear as the entire value or embedded within surrounding text
(as shown by endpoint above). When the entire value is a single expression,
the resolved result preserves its type. When mixed with surrounding text, the
result is coerced to a string.
vault.get
Resolves to the decrypted value of the named secret from the named vault. The
vault service is initialized lazily — only when a vault.get() expression is
encountered. All installed vault types are supported: the built-in
local_encryption provider and extension providers (@swamp/aws-sm,
@swamp/azure-kv, @swamp/1password, and custom vault extensions). Extension
vault bundles are loaded from the .swamp/vault-bundles/ cache during early
boot, so the extension must be installed before referencing it in datastore
config.
datastore:
type: "@swamp/s3-datastore"
config:
bucket: my-swamp-bucket
region: us-east-1
endpoint: "${{ vault.get('infra', 'minio-endpoint') }}"See the Vaults reference for vault types,
vault.get() quoting styles, and the
CEL Expressions reference for the full
expression language.
repoId operator responsibility
repoId is a machine identity — Swamp validates UUID format on the resolved
value but cannot verify that it matches the intended environment's data.
Misconfiguration (e.g., two environments sharing a repoId or a typo producing
a valid but wrong UUID) results in orphaned data with no automated
merge/recovery path.
Limitations
- Only
envandvault.get()are supported. The full CEL evaluation context (model,self,data,file) is not available at this bootstrap phase. - Vault expressions are not supported when
managedConfigistrue. Managed config stores vault configurations in the datastore tier, which is not available during datastore initialization — a circular dependency. Environment variable expressions still work withmanagedConfig. - An unsupported expression (anything other than
env.*orvault.get()) produces a startup error naming the supported namespaces.
Resolution Priority
When multiple configuration sources exist, they are resolved in this order (highest priority first):
| Priority | Source |
|---|---|
| 1 | SWAMP_DATASTORE environment variable |
| 2 | CLI --datastore argument |
| 3 | .swamp.yaml datastore field |
| 4 | Default: filesystem at {repoDir}/.swamp/ |
SWAMP_DATASTORE Environment Variable
Overrides the datastore configuration for a single invocation. Format:
SWAMP_DATASTORE=<type>:<value>| Format | Example |
|---|---|
| Filesystem | SWAMP_DATASTORE=filesystem:/path/to/dir |
| Extension (JSON) | SWAMP_DATASTORE=@swamp/s3-datastore:{"bucket":"my-bucket","region":"us-east-1"} |
| Legacy S3 | SWAMP_DATASTORE=s3:my-bucket/prefix |
The legacy s3:bucket/prefix format is auto-remapped to @swamp/s3-datastore
with the bucket and optional prefix extracted.
Environment variables within the value are expanded (e.g.,
filesystem:$HOME/swamp-data).
$ SWAMP_DATASTORE="filesystem:/tmp/override" swamp datastore status --json{
"type": "filesystem",
"path": "/tmp/override",
"healthy": true,
"message": "Filesystem datastore at /tmp/override is healthy",
"latencyMs": 0.36,
"directories": [
"definitions-evaluated",
"workflows-evaluated",
"data",
"outputs",
"workflow-runs",
"audit",
"telemetry",
"logs",
"files"
]
}Managed Config
When managedConfig: true is set in .swamp.yaml, the datastore stores
configuration alongside runtime data. The config subdirectory within the
datastore holds:
- Behavior definitions (evaluated)
- Workflow definitions (evaluated)
- Vault configurations
- The extension lockfile
- Pulled extension sources
This makes the datastore the single source of truth for configuration. In a
multi-instance swamp serve deployment, all instances read configuration from
the shared datastore rather than from local directories, so a behavior created
on one instance is available on every other instance without manual file
distribution.
The config subdirectory
The config directory sits alongside the existing datastore subdirectories
(data, outputs, workflow-runs, etc.) but is managed separately. It is not
included in the directories list and is not subject to exclude patterns — it
is governed entirely by the managedConfig flag.
Config Refresh Capability
The configRefresh sync capability is required for managed config to work with
extension-provided datastores. It enables the datastore extension to poll for
config changes pushed by other instances.
The S3 datastore (@swamp/s3-datastore) supports configRefresh from version
2026.08.27. The GCS datastore (@swamp/gcs-datastore) supports it from version
2026.08.27.
Without configRefresh, a swamp serve instance cannot detect config changes
made by other instances. The managedConfig flag is accepted in .swamp.yaml
but has no multi-instance effect — each instance sees only its own local writes.
What stays local
The following are never stored in the managed config tier:
.swamp.yaml— the bootstrap configuration file. It must be distributed manually to each instance.- Skills (
.claude/skills/, etc.) — tool-specific instruction files. - Extension kind directories (
extensions/behaviors/, etc.) — user-authored extension source code. - Bundles — derived artifacts rebuilt from sources.
Known limitations
- Last-writer-wins on concurrent config writes. Config changes are infrequent and operative-initiated, so write conflicts are rare in practice. There is no merge or conflict resolution.
- ~30s propagation delay between instances. The ConfigPoller's default interval is 30 seconds. See swamp serve — Config management.
- Migration should run only once. Running
swamp datastore config migrateon multiple instances can clobber index entries. Run it on a single instance and let other instances pick up the config via the poller. .swamp.yamldistribution is manual. Each instance needs its own copy of.swamp.yamlwithmanagedConfig: trueand the correct datastore configuration.
Sync Behavior
Sync applies only to extension-provided datastores that implement a sync service. Filesystem datastores do not sync.
Write commands follow this lifecycle:
- Pull — download changed files from the remote backend to the local cache.
- Execute — run the command against the local cache.
- Push — upload changed files from the local cache to the remote backend.
Read-only commands skip sync entirely.
Change detection compares file size and modification time against a remote index. Transfer concurrency is capped at 10 concurrent file operations.
Cache path
Extension backends use a local cache directory for reads and writes. The sync
service transfers data between this cache and the remote backend. Filesystem
datastores access the configured path directly and have no separate cache.
Manual sync
$ swamp datastore syncTriggers a full pull-then-push cycle. Only available for sync-capable extension datastores. Filesystem datastores return an error:
Datastore sync is only available for sync-capable custom datastores.
Current datastore type: filesystemEnvironment variables
| Variable | Default | Description |
|---|---|---|
SWAMP_V3_RESTORE_PROBE_MS |
4000 |
Bound, in milliseconds, on each listing Swamp makes of a v3 replica while a restore runs. A value that is not a positive integer uses the default. |
While a v3 restore runs, Swamp lists the replica itself, after 2 seconds and
then every 2 seconds, each listing bounded by SWAMP_V3_RESTORE_PROBE_MS. Two
listings in a row that fail on the network stop the restore: a read fails with
datastore_v3_catch_up_unreachable and a write with
datastore_v3_storage_unreachable. Once a listing has answered during a
restore, a later one that only runs past its bound does not count.
Raise the value for a replica whose first listing is always slower than 4
seconds, such as a bucket in a far region, a slow S3-compatible store, or a cold
bucket. Otherwise every read on that checkout that has to catch up fails with
datastore_v3_catch_up_unreachable.
Distributed Locking
Write commands acquire a distributed lock before syncing and executing. The lock prevents concurrent writers from corrupting the datastore.
Lock metadata
| Field | Type | Description |
|---|---|---|
holder |
string | user@hostname |
hostname |
string | Machine name |
pid |
number | Process ID of the lock holder |
acquiredAt |
string (ISO 8601) | When the lock was acquired or last renewed |
ttlMs |
number | Lock duration in milliseconds before considered stale |
nonce |
string (optional) | UUID fencing token for this acquisition |
Lock parameters
| Parameter | Default | Description |
|---|---|---|
ttlMs |
30,000 (30s) | Lock lifetime before considered stale |
retryIntervalMs |
1,000 (1s) | Retry interval when lock is held |
maxWaitMs |
60,000 (60s) | Maximum wait before giving up |
Heartbeat
The lock holder renews the lock every ttlMs / 3 milliseconds (10 seconds at
the default TTL). Each renewal writes a fresh acquiredAt timestamp.
Stale lock detection
A lock is considered stale when either:
- The holder process is dead (checked via OS signal).
- The TTL has expired (
acquiredAt + ttlMs < now).
Stale locks are automatically reclaimed by the next writer.
Nonce fencing
Each lock acquisition generates a unique UUID nonce. Heartbeat renewals verify the on-disk nonce matches the held nonce. If a mismatch is detected (another process reclaimed the lock), the holder self-revokes.
SIGINT handling
When a process receives SIGINT (Ctrl-C) during a locked operation, a best-effort lock release runs before exit.
Per-behavior locks
In addition to the global datastore lock, individual behavior operations acquire per-behavior locks scoped to the behavior type and ID. Both lock types use the same mechanism.
Behavior Leases
In a checkout whose datastore is written through swamp serve (team mode), a
behavior's lock is a lease that serve holds. A command takes the lease for its
own duration. A behavior lease holds it across commands.
Leases exist only in team mode. Any other checkout refuses the lease commands:
Error: Leases are held at serve: this checkout's datastore is not written through serve, so its local locks already keep its commands apartswamp behavior lease acquire
Hold a behavior's lock at serve across commands.
swamp behavior lease acquire <behavior_id_or_name> --for <duration>| Option | Description |
|---|---|
--for |
How long the lease is held between renewals, 5s to 24h (required) |
--repo-dir |
Repository directory (env: SWAMP_REPO_DIR) |
A --for outside that range is refused with --for must be between 5s and 24h.
- Serve first grants the lease for a command's lock TTL, the checkout records
it, and serve then extends it to the
--forhold. A reply lost on the way leaves the lease held only for that short TTL. - Acquiring a lease the checkout already holds renews it and sets the new hold.
- Every command in the checkout renews the lease when it reaches serve, and names it on each commit to the behavior. A command that takes the behavior's lock uses the lease and leaves it held when it ends.
- A lease that no command renews within its hold lapses at serve.
- Leases survive a serve leader takeover: the new leader adopts them.
$ swamp behavior lease acquire my-server --for 30mYou will see output like:
Lease held: my-server (command/shell)
Lock: data/command/shell/0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01/.lock
Fence: 3
Hold: 30m (renewed by each command in this checkout)
Expires: 2026-11-03T21:10:00.000ZA lease the checkout already held prints Lease renewed: instead.
With --json:
{
"behavior": {
"name": "my-server",
"type": "command/shell",
"id": "0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01"
},
"existing": false,
"lockKey": "data/command/shell/0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01/.lock",
"fence": 3,
"holdMs": 1800000,
"expiresAt": "2026-11-03T21:10:00.000Z"
}| Field | Description |
|---|---|
behavior |
The behavior's name, type and id |
existing |
true when the checkout already held the lease and renewed it |
lockKey |
The lock the lease holds |
fence |
The lease's fencing token |
holdMs |
The hold between renewals, in milliseconds |
expiresAt |
When the lease lapses unless a command renews it |
swamp behavior lease release
End the lease this checkout holds on a behavior.
swamp behavior lease release <behavior_id_or_name>| Option | Description |
|---|---|
--repo-dir |
Repository directory (env: SWAMP_REPO_DIR) |
Lease released: my-serverWhen the checkout holds no lease on the behavior:
Lease: this checkout holds none on my-serverWith --json, the command prints behavior, lockKey and released.
swamp behavior lease status
List the leases this checkout holds.
swamp behavior lease status| Option | Description |
|---|---|
--repo-dir |
Repository directory (env: SWAMP_REPO_DIR) |
Each lease is listed as held, or as expired once its expiresAt has passed.
With none held, the command prints Leases: this checkout holds none.
{
"leases": [
{
"lockKey": "data/command/shell/0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01/.lock",
"fence": 3,
"holdMs": 1800000,
"expiresAt": "2026-11-03T21:10:00.000Z",
"state": "held"
}
]
}Fencing and lapses
Serve holds each lease with a fencing token. A commit to a behavior that a live
fenced lease covers is accepted only when it names that lease, so a holder whose
lease has ended, or was taken over, cannot overwrite newer data. A caller with
run but no read on a behavior's data receives the behavior's version floor
with its lease, so its new versions are numbered above versions it cannot see.
The holder measures its lease from its last renewal. When a renewal is refused
(the lease is gone, or the caller's grant was revoked) or does not arrive before
the lease would end, the lease lapses. A swamp behavior run,
swamp workflow run or swamp workflow resume running under it is cancelled,
with the lapse as the cause.
An admin ends an abandoned lease with
swamp datastore lock release --force --behavior.
Compatibility
swamp model lease acquire, release and status are accepted spellings of
the same commands.
Working Offline
A serve-mode checkout keeps working while serve is unreachable, within the rules below. For the steps, see Work Offline Against swamp serve.
A command works offline only when serve is unreachable as it starts and the
checkout's copy has read serve's feed before. It warns once that it works from
the copy, naming its last contact with serve. A command that started online and
loses serve partway fails with exit code 75, as before. A copy that has never
read serve's feed refuses with datastore_v3_serve_unreachable and exit code
75.
What runs offline
| Work | Offline |
|---|---|
| Reads | Runs from the local copy, with a warning that it may be out of date |
read and list methods |
Runs from the local copy; what it records is saved locally |
| A method or workflow step that changes things | Runs only on a behavior whose lease the checkout acquired while online, and only while that lease has not ended by serve's clock |
| Definition edits | Refused with datastore_v3_offline_config_edit, exit code 75 |
A method with no declared kind counts as one that changes things. Without a live
lease, it is refused before it starts, with
datastore_v3_offline_lease_required and exit code 75:
Serve is unreachable, so <method> on <behavior> cannot run: it changes things and needs the behavior's lease, which this checkout does not hold. Nothing was changed. To work offline, take the lease while online: swamp behavior lease acquire <behavior> --for <duration>.Offline, a command does not renew the checkout's leases: each holds until its recorded end. A run under a lease is cancelled if that end passes.
Saved locally
Offline work is saved in the checkout's outbox, and the command exits 0 after warning:
Serve is unreachable, so this work is saved in this checkout and will be sent to serve by the next command that reaches itWith --json, stdout is unchanged and each notice is a one-line JSON object on
stderr:
notice |
When | Other fields |
|---|---|---|
datastore_offline |
The command starts offline | serveUrl, lastContactAt, message |
datastore_offline_queued |
The command saved work locally | serveUrl, queued, txnIds, message |
datastore_offline_flush |
A command sent work saved offline | landed, waiting, rejected, quarantined, renumbered, latest, latestAtEnd |
Later commands, online or offline, read what earlier offline commands saved.
Outbox states
swamp datastore status lists the checkout's outbox entries that are not simply
pending, under Saved In This Checkout.
| State | Meaning |
|---|---|
offline |
Saved while serve was unreachable; sent by a later command. Never dropped. |
rejected |
Could not land; kept with its reason and never sent again. |
quarantined |
Refused because the author lacks a grant it needs; kept for an admin to accept or discard. |
Flush on reconnect
The next command that writes and reaches serve sends the saved entries
(read-only commands never send them). Entries go one at a time in the order they
were saved, each under its original transaction id, so a flush cut off partway
never lands an entry twice. If serve becomes unreachable again, the rest stay
offline.
- Each version written offline is renumbered after the versions written
meanwhile. Nothing already committed is renumbered. Version numbers can have
gaps after a flush, such as
1, 3, 4. Howlatestis chosen after this rebase is described in Latest after an offline rebase. - An entry is sent under its lease while serve still holds it, and otherwise
under no lease, rebased. While another holder's lease covers the behavior, it
stays
offline. - These become
rejected: a delete whose target changed meanwhile, content serve refuses, an entry whose content is missing from the checkout's cache or cannot be rebuilt, and an entry that may have reached serve but is still unsettled after 8 days. - A write refused because the author's grant was revoked is quarantined: serve keeps it, with its content, for an admin.
The command reports what its flush did, with lines like:
Sent 2 change(s) this checkout saved while serve was unreachable
Versions saved offline were renumbered after what landed meanwhile: command/shell/0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01 state 3→5Entries still waiting are reported as
<n> change(s) saved offline are still waiting in this checkout's outbox; a later command sends them.
Quarantine
Serve keeps a quarantined change only when it still refuses the change for the missing grant and the author can read the behavior's data. Serve holds at most 32 MiB of content per change, 32 changes and 128 MiB per author, and 1,024 changes in all. A larger change stays quarantined in the checkout only.
swamp datastore status lists the checkout's quarantined entries. For an admin,
it also lists the changes serve keeps, under Quarantined Changes, with their
transaction ids. An admin keeps a change with
swamp datastore quarantine accept or
drops it with
swamp datastore quarantine discard.
CLI Commands
All datastore commands accept the standard global options (--json, --log,
--log-level, -q, -v, --no-telemetry, --no-color, --show-properties).
swamp datastore status
Show datastore configuration and health.
| Option | Description |
|---|---|
--repo-dir |
Repository directory (default .) |
$ swamp datastore statusDatastore Status
Type: filesystem
Path: /home/user/my-repo/.swamp
Health: ● healthy (0ms)
Dirs: definitions-evaluated, workflows-evaluated, data, outputs, ...$ swamp datastore status --json{
"type": "filesystem",
"path": "/home/user/my-repo/.swamp",
"healthy": true,
"message": "Filesystem datastore at /home/user/my-repo/.swamp is healthy",
"latencyMs": 0.40,
"directories": [
"definitions-evaluated",
"workflows-evaluated",
"data",
"outputs",
"workflow-runs",
"audit",
"telemetry",
"logs",
"files"
]
}In a serve-mode checkout, the command runs locally and adds three sections:
Leases This Checkout Holds (heldLeases), Saved In This Checkout (outbox:
entries in the offline, rejected or quarantined state,
each with its partition, txnId, savedAt and any reason), and, for an
admin, serve's Explicit Leases (explicitLeases) and Quarantined Changes
(quarantine). For anyone else, it says why serve's section is absent
(serveSectionAbsent).
swamp datastore setup filesystem
Configure a filesystem datastore backend.
| Option | Description |
|---|---|
--path |
Absolute path for the datastore directory (required) |
--directories |
Subdirectories to store in the datastore (comma-separated) |
--skip-migration |
Skip migrating existing data from .swamp/ |
--repo-dir |
Repository directory (default .) |
$ swamp datastore setup filesystem --path /data/swamp-store --json{
"type": "filesystem",
"path": "/data/swamp-store",
"filesCopied": 3,
"bytesCopied": 94576,
"directoriesMigrated": [
"definitions-evaluated",
"workflows-evaluated",
"data",
"outputs",
"workflow-runs"
],
"errors": []
}When --directories is specified, only those subdirectories are moved to the
external path. The rest remain in .swamp/.
$ swamp datastore setup filesystem \
--path /data/swamp-store \
--directories data,outputs,workflow-runs \
--json{
"type": "filesystem",
"path": "/data/swamp-store",
"filesCopied": 3,
"bytesCopied": 94576,
"directoriesMigrated": [
"data",
"outputs",
"workflow-runs"
],
"errors": []
}The resulting .swamp.yaml:
datastore:
type: filesystem
path: /data/swamp-store
directories:
- data
- outputs
- workflow-runsswamp datastore setup extension
Configure an extension-provided datastore backend.
| Option | Description |
|---|---|
<type> |
Extension type identifier (e.g., @swamp/s3-datastore) |
--config |
JSON config object for the extension (required) |
--namespace |
Assign a namespace during setup. Equivalent to running namespace set + namespace migrate --yes after setup, but atomic. Preferred for new shared datastores. |
--skip-migration |
Skip pushing local .swamp/ data to the remote. The remote→local hydration step still runs, so the local cache will be seeded from any data already in the configured datastore. |
--hydration-strategy |
Content download strategy: "full" (default, download everything) or "lazy" (metadata only, download content on demand). |
--timeout |
Sync timeout for the initial push and hydration pull, in seconds (max 21600). Overrides SWAMP_DATASTORE_SYNC_TIMEOUT_MS. Raise it when the first push is large. |
--repo-dir |
Repository directory (default .) |
--server |
Run against a remote swamp serve instance (env: SWAMP_SERVE_URL). |
--token |
Server token in <name>.<secret> format; only with --server (overrides stored credentials and SWAMP_SERVER_TOKEN). |
$ swamp datastore setup extension @swamp/s3-datastore \
--config '{"bucket":"my-bucket","region":"us-east-1"}'With a namespace (preferred for shared datastores):
$ swamp datastore setup extension @swamp/s3-datastore \
--namespace infra \
--config '{"bucket":"my-bucket","region":"us-east-1"}'With lazy hydration:
$ swamp datastore setup extension @swamp/s3-datastore \
--hydration-strategy lazy \
--config '{"bucket":"my-bucket","region":"us-east-1"}'swamp datastore sync
Manually sync the local cache with a remote datastore.
| Option | Description |
|---|---|
--pull |
Pull only — fetch remote data to local cache |
--push |
Push only — upload local cache to remote |
--repo-dir |
Repository directory (default .) |
Without --pull or --push, runs a full sync (pull then push).
Only available for sync-capable extension datastores. Filesystem datastores return an error.
$ swamp datastore sync --pull
$ swamp datastore sync --push
$ swamp datastore syncswamp datastore lock status
Show who holds the datastore lock.
| Option | Description |
|---|---|
--repo-dir |
Repository directory (default .) |
$ swamp datastore lock statusLock Status: no lock heldWhen a lock is held, the output includes the holder, hostname, PID, acquisition time, TTL, and nonce.
$ swamp datastore lock status --json{
"held": false,
"datastoreType": "filesystem"
}When a lock is held, held is true and info carries the
lock metadata. Each held per-behavior lock is printed as a
document of its own, with lockScope naming the behavior.
In a serve-mode checkout
A checkout written through swamp serve reads no storage: its locks are the
leases serve holds. The command lists the leases serve holds on locks the caller
could take, including behavior leases, and reports the
datastore-wide lock as not held. The holder is shown only as the caller
(another command of yours) or someone else (another caller), never by name.
If serve cannot be reached, the command fails.
Serve Lease: held [data/aws/ec2/0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01/.lock]
Holder: another caller
Expires: 2026-10-29T12:00:30.000Z (unless renewed)
Lock Status: no lock heldWith --json, the command prints one document, with serve's leases in
serveLeases:
{
"held": false,
"datastoreType": "filesystem",
"serveLeases": [
{
"lockKey": "data/aws/ec2/0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01/.lock",
"heldBy": "other",
"expiresAt": "2026-10-29T12:00:30.000Z"
}
]
}| Field | Description |
|---|---|
lockKey |
The lock the lease holds |
heldBy |
caller (another command of the same principal) or other |
expiresAt |
When the lease ends unless renewed |
serveLeasesTruncated |
true when serve holds more leases than it listed (at most 512) |
swamp datastore lock release
Force-release a stuck datastore lock. This is a breakglass operation for recovering from a process that died without releasing its lock and the automatic stale-lock detection has not yet reclaimed it.
| Option | Description |
|---|---|
--force |
Required to confirm the force release |
--behavior |
Release a specific behavior's lock (type/id format, e.g., aws-ec2/my-server); --model is accepted as a compatibility alias |
--repo-dir |
Repository directory (default .) |
Without --behavior, releases the global datastore lock. With --behavior,
releases the per-behavior lock for the specified behavior.
$ swamp datastore lock release --force --json{
"released": false,
"reason": "no lock held"
}$ swamp datastore lock release --force --behavior aws-ec2/my-serverIn a serve-mode checkout
Without --behavior, the command releases nothing (released: false,
no lock held): serve orders a checkout's writes per behavior, and a checkout
ends its own leases with
swamp behavior lease release.
With --behavior <type/id>, an admin asks serve to end the lease on that
behavior, whoever holds it. This ends an abandoned
behavior lease. The holder's saved work is later sent under
no lease and rebased, never applied over newer data.
Lock Released
Lease held by: user:alice{
"released": true,
"leaseHolder": "user:alice"
}When serve holds no lease on the behavior, released is false with the reason
serve holds no lease on it. If serve ends the lease but cannot remove its
record, the command exits 75 with lease_record_not_removed; running it again
removes the record.
swamp datastore quarantine accept
Land a quarantined change as its original author. Admin only.
swamp datastore quarantine accept <txn_id>| Argument / Option | Description |
|---|---|
<txn_id> |
Transaction id of the quarantined change, as swamp datastore status lists it |
--repo-dir |
Repository directory (env: SWAMP_REPO_DIR) |
The change is rebased onto what landed meanwhile and committed as its author.
The admin's authority covers only the write grant the author lacked: the
change's content and references are judged with the author's current access. A
change the author may not make that way is refused and stays held. Accepting a
change that was already accepted reports (already accepted) and lands nothing
again. The author's next command settles the entry in their outbox.
$ swamp datastore quarantine accept 0f8c57cf-4f22-4233-bf81-ecc6b4492fb8You will see output like:
Accepted: 0f8c57cf-4f22-4233-bf81-ecc6b4492fb8
Partition: model--command%2Fshell--0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01
Author: user:alice (it landed as them)
Accepted: user:admin at 2026-11-03T21:00:00.000Z
Seq: 42
Result: landed - the author's next command settles itVersions renumbered on landing are listed under
Renumbered after what landed meanwhile:.
| JSON field | Description |
|---|---|
txnId |
The change's transaction id |
partition |
The partition the change landed in |
author |
The principal the change landed as |
acceptedBy |
The admin who accepted it |
acceptedAt |
When it was accepted |
seq |
The commit sequence number it landed at |
duplicate |
true when the change had already been accepted |
renumbered |
Versions renumbered on landing, each name, from and to |
A checkout that does not write through serve refuses the command:
Error: This checkout does not write through swamp serve: only serve keeps quarantined changes.swamp datastore quarantine discard
Drop a quarantined change so it never lands. Admin only.
swamp datastore quarantine discard <txn_id>| Argument / Option | Description |
|---|---|
<txn_id> |
Transaction id of the quarantined change, as swamp datastore status lists it |
--repo-dir |
Repository directory (env: SWAMP_REPO_DIR) |
Serve removes the held content and keeps the record as discarded. The author's
next command marks the entry rejected, and it is never sent again. Discarding
a change that was already discarded reports (already discarded).
$ swamp datastore quarantine discard 0f8c57cf-4f22-4233-bf81-ecc6b4492fb8You will see output like:
Discarded: 0f8c57cf-4f22-4233-bf81-ecc6b4492fb8
Partition: model--command%2Fshell--0b6c4bb4-9d61-4f0c-9a43-6f0c1f7b2a01
Author: user:alice
Discarded: user:admin at 2026-11-03T21:00:00.000Z
Result: discarded - it never lands; the author's next command keeps it as rejectedWith --json, the command prints txnId, partition, author, discardedBy,
discardedAt and duplicate.
swamp datastore config migrate
Migrate configuration into the datastore. Copies behavior definitions, workflow
definitions, vault configs, the extension lockfile, and pulled extension sources
into the datastore's config tier. Sets managedConfig: true in .swamp.yaml
if not already set.
| Option | Description |
|---|---|
--repo-dir |
Repository directory (default .) |
The command is idempotent — safe to re-run. A migration sentinel prevents duplicate work: the first run copies config and writes the sentinel; subsequent runs detect the sentinel and skip the copy.
Run this command on one instance only. Running it on multiple instances concurrently can clobber index entries in the datastore. Other instances pick up the migrated config automatically via the ConfigPoller on their next poll cycle.
$ swamp datastore config migrateYou will see output like:
[INF] cli: Set managedConfig: true in .swamp.yaml
[INF] cli: Migrated "models, workflows, vaults, lockfile, pulled-extensions" into datastore config tier
[INF] cli: Pushed config to datastoreThe Pushed config to datastore line appears with a remote datastore.
$ swamp datastore config migrate --json{
"alreadyMigrated": false,
"copiedModels": true,
"copiedWorkflows": true,
"copiedVaults": true,
"copiedLockfile": false,
"copiedPulledExtensions": false,
"managedConfigSet": true,
"configRoot": "/var/swamp/datastore/config",
"pushed": false
}| Field | Description |
|---|---|
alreadyMigrated |
true when the sentinel was present and nothing was copied |
copied* |
Whether each kind of config was copied into the config tier |
managedConfigSet |
true when this run set managedConfig: true in this repository's .swamp.yaml |
configRoot |
Location of the config tier |
pushed |
true when the copied config was pushed to a remote datastore |
When the migration has already been run (sentinel present), the command skips
the copy but still sets managedConfig: true if it is missing, so running it on
another instance that shares the datastore configures that instance:
$ swamp datastore config migrate --json{ "alreadyMigrated": true, "managedConfigSet": false }Setup Pipeline
When swamp datastore setup runs, it follows this sequence:
- Validate — verify the target is accessible (writable directory or reachable remote).
- Migrate — copy existing data from
.swamp/to the new location (unless--skip-migration). See Directory Relocation for which directories move and where they end up. - Verify — compare file counts between source and destination.
- Hydrate — for extension datastores, pull existing remote data into the
local cache. Runs unconditionally regardless of
--skip-migration. - Update — write the
datastorefield to.swamp.yaml. - Clean up — remove migrated subdirectories from
.swamp/.
Directory Relocation
When a datastore is configured on a repository that already has data in
.swamp/, the setup command relocates runtime directories from .swamp/ to the
datastore location. The CLI prints which directories were moved and how many
files were copied.
Which directories relocate
The default set of relocatable directories:
definitions-evaluated workflows-evaluated data
outputs workflow-runsIf directories is set in .swamp.yaml, only those directories are relocated;
the rest stay in .swamp/.
audit/, telemetry/, logs/, files/, and the run .log files under
outputs/ and workflow-runs/ stay in .swamp/. Their writers and readers use
the checkout's own .swamp/, so setup neither copies nor removes them. Run and
output records still move, and keep pointing at their logs in .swamp/.
Directories outside this list — such as auto-definitions/, config/,
secrets/, and internal state files — always remain in .swamp/ and are never
relocated. In particular, local_encryption vault secrets stay local to the
machine even when the rest of the repository's state syncs through a shared
datastore.
Where directories move to
The destination depends on the backend type:
| Backend type | Destination |
|---|---|
filesystem |
The configured path (e.g., /data/swamp-store/) |
| Extension (e.g., S3) | The local cache at ~/.swamp/repos/{repoId}/, then synced to the remote backend |
For filesystem datastores, the directories are moved directly to the configured path. For extension-provided datastores, the directories are moved into the local cache directory; the sync service then pushes them to the remote backend.
Hardcoded path warning
After relocation, the directories no longer exist under .swamp/. Code or
scripts that hardcode paths like .swamp/workflow-runs/ or .swamp/data/ will
break. Use CLI commands to resolve paths programmatically:
$ swamp workflow run search --json # find workflow runs
$ swamp data query '<predicate>' # read data outputs
$ swamp datastore status --json # inspect the active datastore pathPath Resolution
Each file operation resolves to either the local .swamp/ directory or the
configured datastore path:
- If the file's parent subdirectory is in the
directorieslist and does not match anexcludepattern, it goes to the datastore path. - Otherwise, it stays in local
.swamp/.
For extension backends with sync support, the "datastore path" is the local cache directory. The sync service handles transfer between the cache and the remote backend.
Related
- Repository Configuration —
datastorefield in.swamp.yaml - Namespace Commands — CLI reference for
swamp datastore namespace(below) - Giga-Swamp and Namespaces — why namespaces exist and how they work
- Extension Manifest — packaging datastore extensions
- CEL Expressions — full expression
language reference (
env,vault, and other context variables) - Vaults — secrets stored in the
secretsdatastore subdirectory - Data — data stored in the
datadatastore subdirectory - Enable Managed Config — step-by-step guide for multi-instance config convergence
- swamp serve — Config management — architectural decisions behind ConfigPoller and config propagation
Namespace Commands
The swamp datastore namespace command group manages datastore namespaces.
Namespaces scope data within a shared datastore to identify which repository
produced it.
All commands accept the standard global options (--json, --log,
--log-level, -q, -v, --no-telemetry, --no-color, --show-properties,
--repo-dir).
For background on namespaces and shared datastores, see Giga-Swamp and Namespaces.
swamp datastore namespace set
Assign a namespace to this repository.
swamp datastore namespace set <slug>| Argument | Type | Required | Description |
|---|---|---|---|
slug |
string | Yes | Namespace identifier to assign |
| Flag | Description |
|---|---|
--repo-dir |
Repository directory (default .) |
Writes the namespace field to the datastore section of .swamp.yaml and
registers the namespace in the datastore's namespace manifest. Does not move
existing data — run namespace migrate --yes after setting to reorganize data
into the namespaced layout.
$ swamp datastore namespace set infraNamespace set to "infra"
Datastore: /home/user/my-repo/.swamp
Warning: Existing data remains at the old un-namespaced path.
Run 'swamp datastore namespace migrate --yes' to move it
to the namespaced layout.swamp datastore namespace unset
Remove the namespace from this repository.
swamp datastore namespace unset| Flag | Description |
|---|---|
--migrate |
Also reverse-migrate data back to un-namespaced layout |
-y, --yes |
Execute the migration (required with --migrate, ignored otherwise; --confirm also accepted) |
--repo-dir |
Repository directory (default .) |
Removes the namespace field from .swamp.yaml. Without --migrate, data
remains at its namespaced path. With --migrate --yes, data is moved from
.swamp/<namespace>/... back to .swamp/....
swamp datastore namespace migrate
Migrate data between solo and namespaced directory layouts.
swamp datastore namespace migrate| Flag | Description |
|---|---|
-y, --yes |
Execute the migration (without this flag, only a preview is shown; --confirm also accepted) |
--reverse |
Reverse-migrate from namespaced layout back to solo layout |
--repo-dir |
Repository directory (default .) |
Without --yes, displays a preview of the migration: each directory to be
moved, source and destination paths, file count, and total size. No data is
modified.
With --yes, moves each directory from the solo layout (.swamp/<dir>/) to the
namespaced layout (.swamp/<namespace>/<dir>/), or the reverse with
--reverse. The catalog is invalidated after migration and rebuilt on the next
access.
The directories migrated are: definitions-evaluated, workflows-evaluated,
data, outputs, workflow-runs, audit, telemetry.
swamp datastore namespace list
List all namespaces in the datastore.
swamp datastore namespace list| Flag | Description |
|---|---|
--repo-dir |
Repository directory (default .) |
--server |
Run against a remote swamp serve instance (env: SWAMP_SERVE_URL) |
--token |
Server token in <name>.<secret> format; only with --server (overrides stored credentials and SWAMP_SERVER_TOKEN) |
| Output Field | Description |
|---|---|
namespace |
Namespace slug |
repoId |
Repository UUID that registered this namespace |
registeredAt |
Date the namespace was first registered |
current |
* if this namespace belongs to the current repo |
$ swamp datastore namespace list --json{
"namespaces": [
{
"namespace": "infra",
"repoId": "94735c06-fc0a-4d77-b712-04fbd801b18d",
"registeredAt": "2026-05-15T14:30:00.000Z",
"isCurrent": true
}
],
"currentNamespace": "infra"
}swamp datastore catalog pull
Pull catalog metadata from foreign namespaces.
swamp datastore catalog pull --namespaces <namespaces>| Flag | Type | Required | Description |
|---|---|---|---|
--namespaces |
string | Yes | Comma-separated list of foreign namespaces to pull |
--repo-dir |
string | No | Repository directory (default .) |
Fetches catalog entries (behavior names, types, data output names, version counts) from the specified foreign namespaces into the local catalog cache. The pulled metadata is read-only and has no automatic refresh or TTL.
$ swamp datastore catalog pull --namespaces infra,security