session 1 commit 4/4: message envelopes moved to pmacs-protocol

The big move that completes session 1. Wire types moved from
src/protocol.rs to pmacs-protocol/src/message.rs:

- Input event family: Key, Modifiers, KeyEvent, MouseButton, MouseKind,
  MouseEvent, FrontendEvent (and its variants — Resize, KeyEvent,
  MouseEvent, Resume, Pause, Detach, ResizeAck, CrdtOp, Viewport).
- Instance-side message family: CursorState, InstanceSignal,
  GoodbyeReason, InstanceMessage (Hello/Cursor/CellDelta/CursorByte/
  CrdtOp/BufferSnapshot/Goodbye/PresenceUpdate + the SemanticFrame
  variants).
- SelectionSnapshot.
- SemanticFrame family components: StyleSpan, StyleSegment,
  DecorationKind, Decoration, DecorationSegment, AdornmentPlacement,
  AdornmentContent, InlineAdornment, BlockAdornment, ResourceBody.
- Handshake: PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS,
  is_supported_protocol_version, InstanceIdentity, InstanceCapabilities,
  FrontendCapabilities, NegotiatedCapabilities, negotiate_capabilities,
  Hello, AttachRequest.

What stays in src/protocol.rs:
- AttachTarget / AttachError / AttachTargetParseError /
  AttachTargetValidationError / AttachTargetError / AttachmentHandle
  (CLI / binding internals, not wire).
- crossterm_translate submodule (the crossterm ↔ pmacs-protocol-types
  translation layer; sits at the binding boundary, not on the wire).
- Existing tests (wire-format roundtrip + AttachTarget + crossterm
  translation), unchanged — they reach the moved types through the
  'pub use pmacs_protocol::*' re-export.

Mechanical rewrites inside the moved chunk: crate::buffer::BufferId →
crate::BufferId, crate::rope::Position → crate::Position,
crate::rope::CrdtOp → crate::CrdtOp (the message module is inside
pmacs-protocol; identity types live at the crate root).

Feature re-added on pmacs-protocol: 'crdt' (was removed in commit 3
as I'd thought CrdtOp was the only feature-gated thing — but
InstanceCapabilities::default and FrontendCapabilities::default both
call cfg!(feature = 'crdt') for their multi_frontend / crdt_replica /
semantic_render defaults). Re-added with a doc comment explaining why.
The parent pmacs crate's 'crdt' feature now activates
'pmacs-protocol/crdt' so the cfg!() check evaluates consistently in
both crates.

Full gate green: fmt, clippy --all-targets -D warnings, lib 1314,
m4_acceptance 83, m8_1/m8_9/m8_10 10/26/19, m9_1 18, m5_8 5,
m11_5_semantic_acceptance --features crdt 2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Levi Neuwirth 2026-05-20 09:55:27 -04:00
parent 5ffc47aa33
commit a820e91389
5 changed files with 1383 additions and 1350 deletions

View File

@ -72,7 +72,7 @@ lua54 = ["mlua/lua54", "mlua/vendored"]
# field on the Buffer struct layout, no branch on apply_edit). v1.0
# builds enable `crdt`; the rope-projection redirect from M10.1 means
# the feature flip is invisible to v0.1 frontends and to workers.
crdt = ["dep:loro"]
crdt = ["dep:loro", "pmacs-protocol/crdt"]
[dependencies]
crossterm = "0.28"

View File

@ -32,11 +32,15 @@ cast_precision_loss = "allow"
similar_names = "allow"
multiple_crate_versions = "allow"
# No features — the wire type set is unconditional. `CrdtOp` is
# always compiled (matching the original `pmacs::rope::CrdtOp`'s
# "not `#[cfg]`-gated to avoid feature-flag proliferation through
# every Edit consumer" decision); the parent `pmacs` crate's `crdt`
# feature gates loro and op-application, not wire shape.
[features]
# Mirrors the parent `pmacs` crate's `crdt` feature. The wire type
# set is unconditional (`CrdtOp` is always compiled — see
# `crdt.rs`); the feature exists so `cfg!(feature = "crdt")` checks
# inside capability-default helpers (`InstanceCapabilities::default`,
# `FrontendCapabilities::default`) evaluate to the same value here
# as in the parent crate. The parent activates it via
# `pmacs-protocol/crdt` from its own `crdt` feature.
crdt = []
[dependencies]
serde = { workspace = true }

View File

@ -37,12 +37,18 @@
pub mod cell;
pub mod crdt;
pub mod ids;
pub mod message;
pub use cell::{
Attachment, Cell, CellCoord, CellSize, Color, DiffSpan, Glyph, Style, UnderlineStyle,
};
pub use crdt::CrdtOp;
pub use ids::{BufferId, ByteRange, FrontendId, Position};
// The `SemanticFrame` family and the top-level message envelopes
// follow in the final commit within this PR.
pub use message::{
AdornmentContent, AdornmentPlacement, AttachRequest, BlockAdornment, CursorState, Decoration,
DecorationKind, DecorationSegment, FrontendCapabilities, FrontendEvent, GoodbyeReason, Hello,
InlineAdornment, InstanceCapabilities, InstanceIdentity, InstanceMessage, InstanceSignal, Key,
KeyEvent, Modifiers, MouseButton, MouseEvent, MouseKind, NegotiatedCapabilities,
PROTOCOL_VERSION, ResourceBody, SUPPORTED_PROTOCOL_VERSIONS, SelectionSnapshot, StyleSegment,
StyleSpan, is_supported_protocol_version, negotiate_capabilities,
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff