Skip to content

feat(memory): gzip-compress sync blobs before encryption (~3× smaller) - #193

Merged
sandstream merged 1 commit into
mainfrom
claude/headroom-kit-integration-cmjw7t
Jul 1, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/headroom-kit-integration-cmjw7t

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Why

The encrypted memory blob is a full SQLite store — which can exceed a git host's 100 MB file limit (a real large store is ~139 MB). That blocked using a private GitHub repo as the hub for ephemeral sessions (a self-hosted remote has no cap, but GitHub is the zero-SSH, credential-injected path for ephemeral web sessions — see #192).

What

gzip the DB before encryption. A SQLite file compresses ~3×:

store raw blob
this session's real store 6.3 MB 2.1 MB (34%)
large store ~139 MB ~30 MB

Now well under 100 MB, and every transport moves less data.

How (zero new deps, node:zlib)

  • backup.ts: gzipSync the DB in both the passphrase (V2) and public-key (V3) encrypt paths; maybeGunzip on restore. Compression is inside the encryption — the remote still only ever sees ciphertext.
  • Backward-compatible with NO new format version: an older, uncompressed blob decrypts to a raw SQLite file that lacks the gzip magic (0x1f 0x8b), so maybeGunzip passes it through untouched.

Tests

1 new: the blob is < half the raw DB and a passphrase-mode blob still round-trips (compression transparent). All existing backup/asymmetric round-trips still pass. Full suite 1986 green.

Together with #192

#192 (public-key mode) + this (gzip) = GitHub-viable, seamless ephemeral capture: a web session encrypts to a public key (no secret), the blob fits under 100 MB, and it pushes via the injected git credential (no SSH key). The self-hosted remote (ralph-ollama) already works either way.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg


Generated by Claude Code

A SQLite store compresses well (real store 6.3M→2.1M; large ~139M→~30M), which
keeps the encrypted blob under a git host's 100MB file limit and speeds every
transport — making a private GitHub repo viable as the ephemeral-session hub.

- backup.ts: gzip the DB before encrypting (both passphrase V2 and public-key V3
  paths); maybeGunzip on restore. Compression is INSIDE the encryption, so the
  remote still only sees ciphertext.
- Backward-compatible on read with NO new format version: an older uncompressed
  blob decrypts to a raw SQLite file (no gzip magic 0x1f8b) → passed through.

1 new test (blob < half the raw db + passphrase round-trip intact); all existing
round-trips still pass (compression transparent). Suite 1986 green, zero new deps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit e6d3553 into main Jul 1, 2026
17 checks passed
sandstream added a commit that referenced this pull request Jul 1, 2026
#196)

Cut 3.1.0 from [Unreleased]:
- gzip-compress memory sync blobs before encryption (~3x smaller, #193)
- public-key sync mode — ephemeral sessions push with no secret (#192)
- kit agent-config wires GitHub Copilot (#195)
- external timestamp anchor via command transport (#186)
- plus device-identity hardening + transport fixes

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants