Skip to content

refactor: Entry module - #1

Merged
nerdstep merged 7 commits into
mainfrom
entry-module
Nov 25, 2026
Merged

nerdstep merged 7 commits into
mainfrom
entry-module

Conversation

@nerdstep

Copy link
Copy Markdown
Owner

Summary

Each kind of log entry now has one home. Before, a kind was translated by hand in four places across chat.rs and db.rs, and the rule that only an author's own edits and deletes count was repeated in each of them.

 src-tauri/src/
+├── entry.rs   # Entry, Kind, Ref, FileInfo; Wire (a msg frame's body); admission; limits per kind
 ├── chat.rs    # Frame::Msg(Wire); read_loop calls admission
 └── db.rs      # row mapping and the projection (show, current, reactions, scrub)
 read_loop
   Frame::Msg
-    match (delete_of, edit_of, react_to) … reply/vanish/file/limit rules inline
-    build Entry
+    wire.admit(peer, me)        # pure: no Core, Db or clock
   db.insert
   announce
-    if of.author != entry.author: return

A new kind, Kind::Inert, covers entries that are kept in their author's log but never applied, shown or sent:

  • an edit or delete of someone else's message
  • a kind this build doesn't know, left behind by a newer build

Admission and the row decode both produce it, so announce and insert no longer check the author themselves. The SQL in current is the one other place that rule lives.

GLOSSARY.md is new: it defines log, entry, inert entry, admission and message. AGENTS.md points to it.

Also included is configuration for the agent skills: an ## Agent skills section in AGENTS.md and docs/agents/, covering:

  • the issue tracker: GitHub Issues
  • triage labels: the five defaults, now created on GitHub
  • domain docs: one glossary and docs/adr/ at the repo root

Evidence

  • Before (main): a row whose kind this build doesn't know loads as a reply, and catch-up would send it to the peer as one.

    insert row (author=me, kind='pin', ref=peer:1)
    db.since("me", 0)[0].kind
    → Message { reply_to: Some(peer:1), vanish: None, file: None }
    

    After: it loads as inert, and into_wire returns None, so catch-up skips it.

    → Inert { tag: "pin", to: Some(peer:1) }        # db::every_kind_survives_the_log
    
  • Wire format is unchanged: known_frames_keep_their_wire_format and extra_fields_on_known_frames_are_ignored pass with their JSON assertions as they were. Only the code that builds the frame changed.

  • New tests: 7 new tests, all plain #[test]s with no networking:

    • entry::every_kind_survives_the_wire
    • entry::only_one_target_counts: delete > edit > reaction
    • entry::admission_repairs_what_it_can
    • entry::changes_to_someone_elses_message_are_inert
    • db::every_kind_survives_the_log
    • plus the file check test, moved into entry.rs
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (19 unit tests, plus paging and two_peers), and bun run check all pass locally on Windows.

Merge Danger

Door: two-way

There's no schema change and no wire change, so reverting is a plain revert.

Blast Radius: sync

read_loop admission and catch-up are on the path every message takes between peers. Two things could go wrong:

  • If admission differed from the old inline rules, a peer's entries would be stored differently. The new tests cover each rule, and two_peers still passes end to end.
  • Inert entries are skipped in catch-up. The peer's have is the highest entry it holds, so a gap is harmless.

🤖 Generated with Claude Code

nerdstep and others added 7 commits November 25, 2026 07:32
Entry, Kind, Ref and FileInfo get a module of their own, the first step
towards one home for what each kind of entry is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Frame::Msg wraps entry::Wire, and Entry::into_wire replaces to_frame. The
JSON is unchanged: the wire-format tests pass as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Wire::admit turns a msg frame into the entry that's stored, replacing the
inline rules in read_loop. The per-kind limits (text, emoji, lifetime,
files) live in entry.rs, used strictly for my entries and leniently for a
peer's. New tests cover a round trip for every kind, which target counts
when a frame names several, and each repair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Kind::Inert is an entry kept in its author's log but never applied, shown
or sent. Admission and the log both make an edit or delete of someone
else's message inert, so announce and insert no longer check the author
themselves; the SQL in current is the one other place that rule lives.

A kind this build doesn't know (left by a newer build, after going back
to an older one) used to load as a plain message, and catch-up could send
it to the peer as one. It now loads as inert and isn't sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
README's layout lists entry.rs, AGENTS.md points to Wire for the msg
frame's body, and GLOSSARY.md names log, entry, inert entry, admission
and message.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AGENTS.md gets an Agent skills section pointing to docs/agents/: issues
live in GitHub Issues, triage uses the five default labels, and the domain
docs are single-context (GLOSSARY.md and docs/adr/ at the root).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nerdstep
nerdstep merged commit 1ba2507 into main Nov 25, 2026
3 checks passed
@nerdstep
nerdstep deleted the entry-module branch November 25, 2026 16:29
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