Skip to content

fix: keep a previous peer's conversation from a new one - #6

Merged
nerdstep merged 3 commits into
mainfrom
peer-scoped-history
Nov 25, 2026
Merged

nerdstep merged 3 commits into
mainfrom
peer-scoped-history

Conversation

@nerdstep

Copy link
Copy Markdown
Owner

Summary

Unpairing keeps the history on this computer, as the unpair dialog says. Two things went wrong when you then paired with someone new.

1. The new peer received everything written to the previous one. Catch-up sends my entries above the peer's have, and a new peer's have is 0.

 save_peer(id)                    # a key that's new to me
+  shared_after = my max_seq      # peer-scoped setting; same key re-pairing keeps it
 run_session catch-up
-  since(me, their_have)
+  since(me, max(their_have, shared_after)).filter(shares)
 send_live
+  only if shares(entry)

+shares(entry): seq > shared_after, and if it changes or reacts to a message,
+  that message is the peer's, or mine from after shared_after

Editing or deleting older messages still works on this computer; those entries just aren't sent. Pairings from before this have no floor (0), so they carry on exactly as before. There's no wire change.

2. The previous peer's messages showed the new peer's name. nameOf used the current peer's name for every author but me.

+people table (schema 6, filled from the current pairing): id → last known name
 Status
+  people: Person[]
 Transcript
+  nameOf = namer(peopleKey(status.people), myId, peerName)   # stable unless a name changes

Evidence

  • Before (main): a probe test run against main:

    alice pairs bob, sends "a secret for bob", unpairs, pairs carol
    → CAROL SEES: ["a secret for bob"]
    

    After: a_new_peer_gets_only_what_is_written_after_pairing passes. Carol's log from Alice holds only "hi carol" and its edit. That holds even though Alice edited and deleted her old message to Bob after pairing Carol.

  • The new test fails when catch-up goes back to since(me, their_have).

  • messages_keep_their_author_s_name_after_pairing_someone_new covers people: Bob's name is kept after pairing Carol, follows his rename, and lasts across a restart.

  • people_from_before_0_8_are_kept migrates a 0.7 database and keeps its peer's name.

  • a_new_pairing_starts_clean checks that unpairing leaves no receipts or version behind, even across a restart. It fails when unpair stops forgetting peer_version.

  • only_entries_from_after_pairing_are_shared unit-tests shares. people.test.ts tests the namer and its key.

  • Every commit passes bun run check, bun run test, cargo fmt --check, clippy -D warnings and cargo test on its own.

Merge Danger

Door: one-way, for the schema

Schema 6 adds a people table. An older build opening the database ignores the table, so going back to an older build still works, but the migration itself can't be undone. Everything else is a two-way door.

Blast Radius: sync

Catch-up and live sending now pass through shares. If it were wrong, a current peer would miss entries. The protocol tests for catch-up, replacement, edits and deletes, and reactions all still pass, and existing pairings have a floor of 0, so shares only checks targets for them.

🤖 Generated with Claude Code

nerdstep and others added 3 commits November 25, 2026 11:25
Catch-up sent every entry above the peer's `have`, and a new peer's is 0,
so pairing with someone new after unpairing sent them everything written
to the previous one. Pairing with a new key now records shared_after, my
highest sequence number at that moment; shares() keeps catch-up and live
sending above it, and off messages from before it. Pairing again with the
same key keeps the floor, and pairings from before this have none (0), so
they carry on as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The UI named every message that wasn't mine after the current peer, so
after re-pairing, the previous peer's messages showed the new one's
name. A people table (schema 6, filled from the current pairing) keeps
everyone this computer has been paired with by their last known name;
pairing and name changes keep it current, and unpairing leaves it.
Status carries it, and the transcript names each author from it, through
a key that only changes when a name does, so rows don't re-render.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After unpairing, nothing of the previous peer's stays: no receipts, no
version, not after a restart either. Someone new on an older build then
gets a Seen of 0, and neither vanishing messages nor files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nerdstep
nerdstep merged commit ce6c30c into main Nov 25, 2026
3 checks passed
@nerdstep
nerdstep deleted the peer-scoped-history branch November 25, 2026 19:41
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