ragleap-memory 0.3.1: encrypted export and import
Design: #1294. Code: PR #1385. Date fix: PR #1386. Additive, no schema change. Encryption is done by ragleap-security (AES-256-GCM); this package only frames the file.
Behaviour changes (read first)
- Plain export files (format version 1) and every call without the new arguments behave exactly as in 0.3.0.
- Import refuses an encrypted file (header version 2) when no key or passphrase is given, and refuses a plain file when one is given (no downgrade).
- A file whose header says version 2 is now read as an encrypted file. Before, it was refused as an unsupported version.
- New extra: pip install ragleap-memory[crypto] (needs ragleap-security 0.2.0 or newer). Without it nothing else changes, and asking for encryption raises an error that names the extra.
What is new
- export_file(scope, path, encrypt_with=None, passphrase=None, context=None); import_file and import_stream take decrypt_with, passphrase and context. A Key, a KeyRing (rotation) or a passphrase (scrypt, derived once per file).
- Each line is bound to a fixed label, the SHA-256 of the exact header line, its position and your context. A wrong key, a wrong context, any changed byte, and a line that is moved, duplicated or taken from another file all fail with "line N: cannot decrypt". Dropped or extra lines fail the entry count.
- Import stays the single safe path: the same trust cap, scope check, quotas, one transaction and limits apply after decrypting.
What this does not defend
- It protects the export FILE, not the SQLite database, and not process memory while exporting or importing.
- The header shows the number of entries, and line lengths show roughly how long each entry is.
- Someone who holds the key can read and forge a file. An old file put back in place of a newer one is not noticed.
- A decrypted file is still untrusted input. No independent security review has happened.
Verified (real output)
- GitHub CI: 55 of 55 checks passed on the PR head (10aaff3) and on the date-fix PR (31d09c9).
- VPS (Python 3.10.12, SQLite 3.37.2, cryptography 50.0.2): 532 tests passed. Sandbox: 532 on Python 3.12.3 and 3.10.20, and with cryptography 42.0.0.
- Mutation check (sandbox): 232 of 232 killed on Python 3.12.3 and 3.10.20.
- From PyPI: the wheel's 5 Python files are identical to the source at the tag; fresh installs work with and without [crypto]; the 532 tests from the source archive pass against the installed wheel; a database and an export file written by the real released 0.3.0 open and import; the released 0.3.0 refuses a 0.3.1 encrypted file with its unsupported-version message.
Not verified
- The mutation run on the VPS. Windows and macOS. Several processes using one file; network file systems; big-endian machines.
- Timing and memory with very large files: an import decrypts into memory up to max_bytes (64 MiB by default).
Provenance
- Tag ragleap-memory-v0.3.1 on c1a22ff. Uploaded to PyPI 2026-11-12T10:09:29 UTC by the Release workflow (environment pypi).
- Wheel sha256 a4057312ade8b3a1fa204a1e22d4a2cc07071eba4869934f3f5a7b4db0a5ee4f
- Source archive sha256 8ecdb596ba0174737344489a49e14f93610c7ff183f030eee8a55f24199de691
- The provenance records of the wheel and of the source archive were decoded: repository ragleap/ragleap-core, workflow release.yml, environment pypi, digests identical to the files.