Finalize immutable message hashes before delivery - #44
Merged
Conversation
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.
Local-only messages now acquire their protocol SHA-256 atomically with
time_sent. The shared finalizer freezes header encoding, compression metadata and durable wire payloads; federation and challenge responses use that finalized representation. Add-to batches receive independent identities, and replies wait for known pending parent deliveries.Sent identities and content are immutable.
dd.sqlis a bootstrap schema for an empty database, with no upgrade statements or legacy exemptions. Normal daemon/API operation requires finalized storage and never backfills or guesses an old wire form during delivery.Existing installations upgrade offline with one statically linked
fmsg-backfillbinary. It embeds the schema upgrade, preserves timestamps/IDs/published hashes, backfills local-only reply trees, and prepares existing federated messages and batches. The default runs the full conversion then rolls back;-applycommits schema and data in one transaction. Failed reconstruction rolls everything back. Stop both services and back up the database and payload directory before running it; start matching service versions after success, without rerunningdd.sql. The binary is separate from the daemon image.Contract: markmnl/fmsg#37. API: markmnl/fmsg-webapi#45. Docker: markmnl/fmsg-docker#21. Merge the daemon before API and Docker.
Validation: builds, Go tests, PostgreSQL finalization/migration/immutability tests, race checks and vet passed. Migration coverage includes dry run, repeat verification, published string/compressed hashes, received attachments, add-to-only originals, drafts, and complete rollback after missing/corrupt data. The static binary also passed dry-run/apply/repeat verification outside the source checkout. The coordinated Docker suite passed all 15 tests with forced challenges. CI runs the PostgreSQL tests and selects matching companion branches for federation tests.