bug(node): mailbox ack compaction overwrites the identity WAL with envelope records, destroying the identity log on restart

Open
#16 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
38/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend, databases

Research direction

Start with the ack path in src/http_relay.rs and WAL compaction in src/s3_wal_maintenance.rs, then trace identity replay in src/storage.rs. Separate the identity and envelope WAL schemas, ensure appends are synced before acknowledgment, and restore both data types during startup replay. Add a regression test for ack, compaction, and restart; done when identities remain intact and queued envelopes are restored.

Written by the indexing model from the issue text.

Description

area::node effort::m impact::high priority::medium source::auto status::review type::bug

Context

Full-ecosystem production-readiness audit (2026-11-18). The mailbox-ack path reuses the identity WAL file for envelope records, mixing two incompatible line schemas in kt_log.wal. Milestone 6 (#6, status::review) claims durable WAL recovery; in reality the ack path actively destroys the identity log.

Symptom and mechanism (evidence)

  1. POST /v1/relay/mailboxes/{id}/ack calls compact_wal_file(wal, &active) where wal is the identity WAL path (src/http_relay.rs:189-192), and compact_wal_file rewrites that same file with the surviving envelope records in a second, incompatible schema (src/s3_wal_maintenance.rs:14-39).
  2. On restart, replay_wal_into_log tries to parse every line as an identity WalEntry (src/storage.rs:53-67); the envelope lines fail, load_wal_entries returns Err, and unwrap_or_default() at src/storage.rs:122 silently discards the entire identity log (DIDs and key commitments).
  3. The compacted envelopes are never reloaded into the MailboxStore either — replay only reconstructs identities (src/storage.rs:114-143), so envelope data compacted during ack is lost as well.

Impact

High: after any mailbox ack followed by a container restart, all registered identity state vanishes. This is a silent data-loss path in the core node, currently reachable in the deployed sandbox configuration.

Acceptance criteria

  • Separate WAL files per domain (identities vs. relay envelopes) — one file, one schema.
  • fsync (sync_all) on WAL append before acknowledging the write.
  • Replay reconstructs both identities and queued envelopes on startup.
  • Regression test: ack → compaction → restart → identity log intact and envelopes restored (this exact scenario is untested today; the existing compaction test uses a separate file, tests/milestone10_node_test.rs:153-180).
Dominant language
Rust
Stars
0
Forks
0
Avg merge
4m
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from alfonsodg/sonaraim-node

All issues in alfonsodg/sonaraim-node

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.