hub: upstream improvements for identity
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 255
- Forks
- 17
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 109
Description
Upstream Improvements
1. Expose set_actor in automerge WASM bindings (automerge/automerge)
The Rust automerge crate has doc.set_actor(ActorId) — a single field assignment with no allocation or copying. But the WASM bindings (automerge_wasm_bg.js) don't expose it. The only way to change the actor from JS is Automerge.clone(doc, { actor }), which copies the entire document.
Adding setActor(actor: string) to the WASM Automerge class is a one-line binding to the existing Rust method. The JS layer would then expose it as Automerge.setActorId(doc, actorId) or similar. This would let us replace:
// Current: clone entire document to change one field
handle.update(doc => Automerge.clone(doc, { actor: actorId }))
// With set_actor exposed: mutate in place, no allocation
handle.update(doc => { Automerge.setActorId(doc, actorId); return doc })
Priority: low. The clone is safe (no sync side-effects, old doc is GC'd) and cheap for our document sizes. But it's the right fix long-term.
2. Add actor option to Repo.create() / Repo.find() (automerge/automerge-repo)
Ideally, Repo.create() and Repo.find() would natively accept an actor option:
repo.create<T>({ actor: hexActorId })
repo.find<T>(docId, { actor: hexActorId })
This would eliminate the update+clone workaround and all its downsides:
- Noise in history:
create()writes one change with a random actor before the clone switches to the real one. That random actor is permanently baked into the document. - Performance:
Automerge.clone()copies the entire document just to change the actor ID.
Migration would be straightforward — update the createDoc/findDoc helpers to pass the native actor option and remove applyActorId.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with automerge/automerge's existing Rust doc.set_actor implementation and the automerge_wasm_bg.js bindings, then inspect automerge/automerge-repo's Repo.create(), Repo.find(), createDoc, findDoc, and applyActorId paths. Confirm the native actor options and binding shape in those entry points; done means both APIs accept the requested actor without the clone workaround and existing create/find behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rust, typescript, wasm
- Domain
- api, backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100