Skip to content
potluckdb

Start here

↑ ↓ Select↵ OpenEsc Close

Advanced

Advanced operations remain typed and separate from the ordinary path. Options and calls use Python spellings. Each language’s reference gives its own spellings.

Publish a verified retained source snapshot into an unpublished target namespace under a new encryption key.

admin.reencrypt(
source: Remote,
target: Remote,
new_key: bytes,
*,
source_key: bytes | None = None,
revision: str | None = None,
) -> KeyRotationReport

Parameters

  • source: The remote holding the retained source revision.
  • target: The distinct, unpublished target remote.
  • new_key: The new 32-byte encryption key for the target.
  • source_key: The source revision’s encryption key, if encrypted.
  • revision: The retained source revision, or the current head if omitted.

Returns

KeyRotationReport. The source and target revisions and publication result.

Errors

  • invalid_argument: An argument has the wrong type or value.
  • remote_closed: The remote is closed.
  • invalid_state: The source has no published revision, both keys are equal, or the target cannot accept the rotated data.
  • integrity_failure: A record failed its integrity check during the rotation.
  • wrong_key_or_corrupt: The current key is wrong, or encrypted data is damaged. Check source_key and preserve damaged data.
  • encryption_key_required: The source is encrypted, but its key was not supplied. Pass its current key as source_key.

Other errors can occur. See Errors for every code.

Example

from potluckdb import OpenOptions, Remote, SyncPolicy, admin, open
import secrets
options = OpenOptions(sync_policy=SyncPolicy.manual())
directory = Remote.from_directory
with directory("source") as src, directory("target") as dst:
with open("notes", src, options) as db:
db.execute("CREATE TABLE note (id INTEGER PRIMARY KEY)")
db.sync()
report = admin.reencrypt(src, dst, secrets.token_bytes(32))
print(report.published)
Details

Supply distinct source and target remotes that you own. The operation uses bounded transfers. After partial immutable uploads, retry with the same new encryption key. Once the target head is published, repeated calls have the same effect. The target head publishes only after every object write completes.

This call does not close either remote. Both remotes stay reserved until the call returns, whether it succeeds or fails.

The integrator namespace holds the low-level runtime and storage entry points for cooperative hosts.

A database is a directory, not a single file. Inside it:

FileWhat it is
potluckdb_runtime-local-v1.binYour data. Every page lives here.
potluckdb_runtime-engineEmpty, and the one to know about (below).
potluckdb_runtime-engine-wal, potluckdb_runtime-engine-journalEmpty, for the same reason.
potluckdb_runtime-local-v1.lockCoordination between processes.
.potluckdb-client-idThis device’s identity.

potluckdb_runtime-engine is the name SQLite opens the database under, and it is always zero bytes. Nothing is ever written through it: a custom virtual file system intercepts every read and write and serves them from potluckdb_runtime-local-v1.bin. The real file exists because SQLite’s locking protocol needs something on disk to lock.

Opening it with the sqlite3 command line tool reports no such table even for existing tables. You are reading the lock file. Your data is in potluckdb_runtime-local-v1.bin. Query through the SDK.

Deleting these empty files loses nothing, and they come back on the next open.