Skip to content

Live co-editing: a compact way to send a body's display mesh to the others in a session, whole or as changes (#5184) - #7685

Draft
CamWight wants to merge 13 commits into
tangency-labs:mainfrom
CamWight:coedit-wire-5184
Draft

CamWight wants to merge 13 commits into
tangency-labs:mainfrom
CamWight:coedit-wire-5184

Conversation

@CamWight

@CamWight CamWight commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Live co-editing: a compact way to send a body's display mesh to the others in a session, whole or as changes (#5184)
Nothing changes for the person using SolidCraft yet: nothing sends it. Live co-editing needs to show everyone the model as it changes, so a body's display mesh has to travel between computers quickly. This adds a compact format for that mesh, sent whole or as only what changed.

A live co-editing slice (#5184, claim #7547): how a body's display mesh travels to the other people in a session. Nothing sends it yet.

#7682 (the testkit crate) has landed, so this PR holds only its three own commits: the crate, its acceptance checks in CI, and the review's changes to the wire (sizes, names, coordinates, triangles, single faces).

Changes a default: no

The codec

solidcraft-collab-wire is in layer L1: pure, no I/O, and it builds for wasm.

Chunks: it sends a display mesh as one chunk per B-rep face, keyed by the face's persistent name and a SHA-256 content hash.

  • Positions sit on a 1 µm grid, as zig-zag delta varints.
  • Normals are octahedral, 2 × 16-bit.
  • Corners are delta-coded, and the whole is deflated.
  • Each face is written in one canonical form: triangles start from their least corner, are sorted, and equal corners are welded. So a face that comes out of the mesher the same on the grid keeps its hash.
  • A triangle with no area on the grid (two corners on one grid point) is left out when encoding: nothing would draw it.

Shapes and bodies: a shape keeps its faces in name order and is keyed by the hash of their hashes, so its hash doesn't follow the B-rep's face numbering. A body is a shape hash plus an exact f64 placement.

Deltas: a shape message is either whole or a delta. A delta carries:

  • the hash of a shape the receiver holds;
  • the names of the faces it loses;
  • the faces that are new or changed.

Unchanged faces cost nothing. Faces the sender knows the receiver holds go as their hash. A receiver without the base refuses the delta, and the sender then sends the shape whole.

On the sensor enclosure: moving the USB cut-out costs the Case 5.3 KB instead of 9.9 KB (reference mesh), and the unchanged Lid costs 40 bytes instead of 1.2 KB.

One face alone: a face can also travel by itself as a blob (FaceChunk::to_blob, from_blob), so a receiver can ask for one face it lacks. Splitting a blob longer than one frame into pieces is the transport's job (W1).

Which mesh goes where: the crate doc says which mesh each audience gets. Collaborators who hold the design get the reference mesh; Viewers get the Normal display mesh. A body imported as a mesh goes as one face, as its mesh already comes.

Hostile bytes

Every decoder takes bytes from someone else:

  • Declared sizes: every message starts with its inflated size (at most 64 MiB). Inflating stops one byte past that size, and anything but exactly that size is refused, so a decompression bomb stops at what it declared.
  • Caps: on faces, vertices, triangles, face names (4 KiB each, 4 MiB in one shape).
  • Before anything is reserved: counts are checked against the bytes left. Cutting a face reserves room for at most the vertex cap.
  • Encodings: varints must be in their shortest form; coordinates and placements must be finite and within 1e9 mm (1,000 km, far past any design); corners must be in range, and a triangle may not repeat a corner.
  • The receiver's store: what it hands back is checked against the hash asked for.
  • Refused:
    • removed names the base lacks;
    • names out of order or given twice;
    • a face both removed and changed.

Tests

  • Round trips, whole and as deltas.
  • Every refusal above.
  • Fuzzed with testkit's mutator: shape messages deflated, and their insides before deflating.
  • In CI (the second commit): a box, the box filleted and a short modelled thread, at reference and display quality. The triangles come back, and each edit sent as a delta rebuilds the shape after it.
  • Ignored measurements, printing their numbers:
    • the sensor enclosure;
    • what an imported 10k-triangle mesh costs as one face, as a face per triangle, and without its normals.
  • Planted faults: 43 of 43 caught, then a clean run that passes.

Checks

Latest, on this head 38461fce6 over main 8312bf0cb, local, Windows, --profile ci: fmt and xtask layers pass; the workspace builds with all targets; clippy -D warnings on collab-wire and engine, all targets, passes; solidcraft-collab-wire: 16 passed, 0 failed; the engine's size checks on real bodies: 1 passed, 2 ignored (the two measurements that only print). No full gate on this head.

What this rebase changed:

  • Cargo.toml and Cargo.lock: main pinned solidcore's crates beside this crate's line; both are kept, the crate at the workspace's 0.40.0-rc.2.
  • xtask layers and docs/architecture.md: main added dynamics at L1 beside collab-wire; one L1 row names both.
  • Vec3: the crate takes it from solidcore_record, where it now lives, with solidcraft_geom's methods through its prelude, and depends on solidcore-record for it.
  • Session::world_state() now returns a Result; the size checks on real bodies unwrap it, as tests do.

Before, on 8d3825e10 over main 6cee7a91b, local, Windows, --profile ci: fmt and xtask layers pass; cargo check --locked on collab-wire and engine with their tests passes; clippy -D warnings on both, all targets, passes; solidcraft-collab-wire: 16 passed, 0 failed; the engine's size checks on real bodies: 1 passed, 2 ignored (the two measurements that only print). No full gate on this head.

What this rebase changed: the testkit commits went, as #7682 landed, and the crate's line in Cargo.lock is at the workspace's 0.30.1, in the commit that adds it. Nothing else conflicted.

Before:
Local gate (Windows) over the whole co-editing stack (#7682, #7683, #7684 and this PR together) on main 66bd64c:

  • every commit builds on its own;
  • fmt, clippy, assets, icons, licences, lists, layers, ui-containers, wasm and web offline pass;
  • every crate's tests (the stack changes Cargo.lock, so all of them run): 10,104 passed in 86 test binaries, 71 ignored, none failed.

Then each PR's branch was rebased onto main ab67126. The only conflict was two new tests side by side in doc/src/tests.rs; both are kept. The new crates' Cargo.lock lines are at the workspace's 0.27.1. On that main, each branch builds with its lock as committed (cargo check --locked --tests), and each slice's own tests pass again:

  • design compare: solidcraft-doc library, 517 passed;
  • roles: the engine's collaboration tests, 33 passed;
  • wire: solidcraft-collab-wire, 16 passed, and the engine's size checks on real bodies.

@github-actions github-actions Bot added area:infra CI, tooling, repo, docs area:io import/export and file formats (STEP, IGES, 3MF, glTF, designs) labels Oct 27, 2026
@CamWight CamWight changed the title Co-editing: a wire crate with the compact mesh codec, whole or as a delta (#5184) Live Co-Editing: a wire crate with the compact mesh codec, whole or as a delta (#5184) Oct 29, 2026
@CamWight
CamWight force-pushed the coedit-wire-5184 branch 3 times, most recently from a63d8c9 to e84db5e Compare October 30, 2026 12:47
@CamWight CamWight changed the title Live Co-Editing: a wire crate with the compact mesh codec, whole or as a delta (#5184) Live co-editing: a compact way to send a body's display mesh to the others in a session, whole or as changes (#5184) Nov 2, 2026
@CamWight
CamWight force-pushed the coedit-wire-5184 branch 2 times, most recently from 8d3825e to 38461fc Compare November 5, 2026 16:35
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@CamWight
CamWight force-pushed the coedit-wire-5184 branch 5 times, most recently from 8cf42e9 to 3e0bf6c Compare November 8, 2026 17:57
CamWight and others added 3 commits November 9, 2026 00:14
…elta (tangency-labs#5184)

`solidcraft-collab-wire` (L1: pure, no I/O, builds for wasm) sends a display mesh as one chunk
per B-rep face, keyed by the face's persistent name and a SHA-256 content hash: positions on a
1 µm grid as zig-zag delta varints, octahedral 2 x 16-bit normals, delta-coded corners, deflated.
Each face is written in one canonical form (triangles from their least corner, sorted, equal
corners welded), so a face that comes out of the mesher the same on the grid keeps its hash. A
shape keeps its faces in name order and is keyed by the hash of their hashes, so its hash
doesn't follow the B-rep's face numbering; a body is a shape hash and an exact f64 placement.

A shape message is whole or a delta: the hash of a shape the receiver holds, the names of the
faces it loses, and the faces that are new or changed. Unchanged faces cost nothing, and faces
the sender `knows` the receiver holds (`Held`: its shapes and chunks) go as their hash. A
receiver without the base refuses the delta, so the sender sends the shape whole. On the sensor
enclosure, moving the USB cut-out costs the Case 5.3 KB instead of 9.9 KB (reference mesh), and
the unchanged Lid 40 bytes instead of 1.2 KB. The crate doc says which mesh each audience gets:
the reference mesh for collaborators who hold the design, the Normal display mesh for Viewers;
a body imported as a mesh goes as one face, as its mesh already comes.

Every decoder takes hostile bytes: caps on faces, vertices, triangles, inflated size (a
decompression bomb stops at 64 MiB) and face names (the plan's 4 KiB), counts checked against
the bytes left before anything is reserved, varints in their shortest form, coordinates within
geom's 1e12 mm, corners in range, what the receiver's store hands back checked against the hash
asked for, removed names its base lacks refused, as are names out of order or twice and a face
both removed and changed. Cutting a face reserves room for at most the vertex cap. Fuzzed with
testkit's mutator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…angency-labs#5184)

A box, the box filleted and a short modelled thread, at reference and display quality: the
triangles come back, and each edit sent as a delta rebuilds the shape after it. The sensor
enclosure measurement stays ignored, now printing its longest face name, and a second ignored
measurement prints what an imported 10k-triangle mesh costs as one face, a face per triangle and
without its normals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…checks; a face can travel alone (tangency-labs#5184)

The combined network and security review's changes to the mesh codec:
- every shape message and face blob starts with its inflated length; nothing inflates past it
  (one byte past at most) and anything but exactly that length is refused, so a receiver knows
  what a message costs before inflating it (`declared_size`);
- at most 4 MiB of face names in one shape;
- a display bound of 1e9 mm for positions and placements (the GPU path's own), a triangle that
  repeats a corner is refused, and the encoder leaves out triangles with no area on the 1 um
  grid (the M6 thread's reference mesh has 144);
- a face can travel alone as the blob a receiver pulls by id (`FaceChunk::to_blob` /
  `from_blob`). Cutting a blob longer than one frame into pieces is the blob layer's rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CamWight and others added 6 commits November 11, 2026 19:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CamWight and others added 4 commits November 25, 2026 10:33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:infra CI, tooling, repo, docs area:io import/export and file formats (STEP, IGES, 3MF, glTF, designs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant