cmux-tui: the build adoption replays a post-update home's event journal before it moves its chats

Merged
LA
18h ago
+84-0

Summary

R-DURABILITY, the build-adoption journal (a data-loss gap that store.journal default-on needs closed first).

When NEXT's post-update acpmux home exists, the build adoption (cmux-tui build_adopt, run at app launch by __adopt-build-homes) sets that home aside and moves only its sessions/ folders into the adopted home. Its journal/ stays aside, where nothing replays it. If that home's daemon stopped without a shutdown while store.journal was on, a chat made after the update has its log line in its log but its session.json only in the journal past its checkpoint. The adopted home then gets the chat's log and no session.json, and no daemon lists the chat again.

What changes

  • acpmux: store::catch_up_journal(config, home) writes a home's event journal into its chat folders, checkpoints it and retires its records (the existing journal_store::catch_up, now public), for code that moves chat folders without a daemon. Nothing to do without a journal.
  • build_adopt: before any move, under both homes' daemon locks, it replays the post-update home's journal. If that fails, the adoption is deferred and nothing has moved. A leftover aside from an earlier run is replayed before its merge, and kept for a later run if it does not replay.

Testing

Red at 48a7a6988d3: a_post_update_chat_that_only_its_journal_holds_is_adopted_whole (cmux-tui/tests/next_home_adoption.rs) fails at its own assertion (line 439, the adopted home has no session.json for the chat), in the full run and alone: Linux fleet 580e7b2e. The macOS red run (85d84bc7) did not compile because of a base red in cmux-host (fixed by #36672).

Command: cmux-ci run --class isolated --script scripts/ci/cmux-tui-rust-check.sh --ref <sha> --os <linux|macos> --arg test --arg <filter>.

Green at 50eff740d96 (feat merged in), filter post_update (the three tests of the merge path): running, Linux 0cbbe2be and macOS 56fd551f.

Observed / Not run

  • Observed: the fleet steps above, each log read.
  • Not run: an adoption on a real person's home with a crashed post-update daemon; Windows (build_adopt is Unix only).

Changelog

none

Proof

No capture: a launch-time folder merge with no UI.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Fixes a data-loss gap in the build adoption (cmux-tui build_adopt): when a post-update home's daemon stopped without a shutdown while store.journal was on, a chat made after the update was moved with its log but no session.json, so no daemon listed it again. The adoption now replays that home's event journal before moving any chat folders.

  • Adds acpmux::store::catch_up_journal, which writes a home's event journal into its chat folders, checkpoints, and retires the records (reuses the existing journal_store::catch_up).
  • build_adopt replays the post-update home's journal under both homes' daemon locks before any move; on failure the adoption is deferred and nothing moves.
  • A leftover aside from an earlier run is replayed before its merge; if it does not replay, it is kept for a later run.