feat(core): add encrypted projection snapshot canary - #1488
Merged
Conversation
This was referenced Jul 13, 2026
…-cleanup-v2 * origin/main: fix(security): restrict public server assets (#1499) test(frontend): strengthen design system guardrails (#1516) refactor(frontend): codify the design system (#1514) fix(config): configure API response compression (#1502) fix(frontend): hide deleted users from membership events (#1504) fix(dockercompose): use muxed LiveKit UDP port (#1503) feat(shields): add Shields.io community badges (#1467)
…-cleanup-v2 * origin/main: perf(realtime): centralize myEvents fanout (#1513) # Conflicts: # docs/adr/INDEX.md
hmans
added a commit
that referenced
this pull request
Jul 15, 2026
…e-mapping * origin/main: (35 commits) feat(frontend): add inline message timestamps (#1558) docs(architecture): improve inventory readability (#1555) perf(connect): reuse DEKs across request hydration (#1554) docs(architecture): split runtime inventory by category (#1552) fix(core): decrypt projected user PII on demand (#1551) fix(frontend): avoid blank line when enabling rich mode (#1548) feat(rooms): add joinable room previews (#1546) feat(core): bound projection snapshot cleanup (#1538) fix(frontend): restore subtle design colors (#1545) fix(core): preserve cleared RBAC defaults (#1543) fix(pwa): use server name for installed app (#1542) fix(frontend): show pending permission updates (#1540) fix(frontend): collapse invisible markdown spacing (#1539) feat(frontend): expand lazy-loaded locale support (#1537) refactor(frontend): modernize and align the design system (#1518) feat(core): add encrypted projection snapshot canary (#1488) fix(frontend): allow app-wide mobile sidebar swipes (#1534) ci: add remote server compatibility smoke test (#1531) feat(frontend): add regional English locales (#1532) fix(frontend): support remote-only sessions (#1530) ... # Conflicts: # cli/internal/core/external_identities.go # docs/ARCHITECTURE.md # docs/adr/INDEX.md # docs/fdr/FDR-001-roles-and-permissions.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Projection startup cost grows with retained EVT history, but adding snapshots
introduces compatibility, confidentiality, storage, and multi-replica failure
modes. This PR adds a disabled-by-default Thread projection canary so we can
validate that machinery without expiring EVT or making snapshots part of
recovery correctness.
Closes #1496. Advances #1491 and #1034. A Thread-only snapshot intentionally
does not reduce total startup wall time while all projections share one full
EVT replay fanout.
What changed
core.projection_snapshotsconfiguration and theCHATTO_CORE_PROJECTION_SNAPSHOTSoverride, both off by default; the checked-indevelopment
cli/chatto.tomlenables the canary for local evaluationskip-through replay, diagnostics, and an atomic state-plus-EVT-sequence
capture barrier
SERVER_ASSETSor theconfigured S3 backend using deterministic protobuf, gzip,
XChaCha20-Poly1305, and an HKDF key derived from
core.secret_keypointer, with fallback, validation, current/previous referenced retention, and
failed-publication cleanup
threads-v1codec, which excludes message bodies and decrypted PII,rebuilds derived indexes, restores transactionally, and derives follow state
exclusively from durable EVT facts
thread_follow.*runtime markers;those records remain inert in
RUNTIME_STATEand are not deletedMEMORY_CACHElease and treatevery snapshot load, restore, lease, storage, and cleanup failure as an
optimization failure that leaves normal EVT-backed service available
JetStream backup/restore path, and retry the NATS stream-creation race seen
when replicas initialize an empty account concurrently
multiple goroutines, so backup statistics remain race-free
backup, configuration, documentation rules, and backend-agent guidance
Compatibility and operations
expiration, truncation, compaction, or archival.
opaque EVT incarnation ID stored in stream metadata. Missing, corrupt, stale,
future, or undecryptable state causes a cold replay. Snapshot loads have a
15-second startup deadline, and the canary rejects projection payloads larger
than 64 MiB to bound transient memory.
but changes when EVT is deleted and recreated. Missing identity metadata is
deterministically derived once from the stream creation time so concurrent
replicas converge, then persisted. Snapshot restore and generation use the
immutable value captured during core setup.
pre-EVT
thread_follow.*runtime markers are no longer imported after arestart. Current follow/unfollow choices are durable
ThreadFollowedEvent/ThreadUnfollowedEventfacts in EVT.fallback. Crash, stale-writer, and key-rotation orphan cleanup remains tracked
in feat(core): productionize snapshot lifecycle and operations #1494 before broader production use.
core.secret_keyinvalidates snapshots but does not lose domaindata. NATS-backed snapshots are included in
chatto backup; S3-backedsnapshots follow the deployment's S3 backup policy.
surface. It is additive and snapshots using unknown compatibility IDs are
disposable.
Test plan
mise test-cli(pass after merging currentmain)mise x -- go test -race ./internal/projectionsnapshot ./internal/events ./internal/core -run 'Snapshot|Envelope|Repository|ThreadProjectionSnapshot|EVTStream'(pass)no replacement generation, rejection after EVT recreation, and convergent
concurrent initialization
TestBackupRestoreRoundTrippreserves the EVT incarnation metadata andprivate projection snapshot object bytes on a fresh NATS server
mise lint(pass: Svelte check and ESLint)mise license-check(pass)mise codegen-proto(pass; generated tree clean)mise x -- pnpm buildinapps/docs-website(pass)mise x -- go test ./internal/core -run '^$' -bench BenchmarkThreadProjectionSnapshotCodec -benchtime=1x(pass at 1,000 and 10,000 messages)mise x -- go vet ./...still reports two pre-existing protobuf lock-copywarnings in
internal/core/config_manager_test.goandinternal/core/voice_test.go; this branch does not touch either site.