Skip to content

Finalize immutable message hashes before delivery - #44

Merged
markmnl merged 6 commits into
mainfrom
feat/finalize-message-sha256
Sep 10, 2026
Merged

Finalize immutable message hashes before delivery#44
markmnl merged 6 commits into
mainfrom
feat/finalize-message-sha256

Conversation

@markmnl

@markmnl markmnl commented Sep 10, 2026

Copy link
Copy Markdown
Owner

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.sql is 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-backfill binary. 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; -apply commits 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 rerunning dd.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.

@markmnl
markmnl merged commit 887df02 into main Sep 10, 2026
2 checks passed
@markmnl
markmnl deleted the feat/finalize-message-sha256 branch September 10, 2026 08:40
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.

1 participant