refactor: extract shared notebook-doc crate, eliminate WASM copy drift#562
Merged
refactor: extract shared notebook-doc crate, eliminate WASM copy drift#562
Conversation
Eliminates WASM copy drift — both runtimed (daemon) and runtimed-wasm (frontend) now depend on one source of truth for the Automerge notebook document schema and operations. Changes: - git mv runtimed/src/notebook_doc.rs → notebook-doc/src/lib.rs (history preserved) - Delete runtimed-wasm/src/notebook_doc.rs (was a diverging copy) - File I/O methods (load_or_create, save_to_file) gated behind 'persistence' feature - StreamOutputState moved from stream_terminal.rs to the shared crate (2-field struct, no external deps) — runtimed re-exports it - NotebookDoc gains doc()/doc_mut() accessors for extension by consumers - runtimed depends on notebook-doc with features=["persistence"] - runtimed-wasm depends on notebook-doc (no features) Tests: 23 notebook-doc (19 core + 4 persistence), 233 runtimed, all passing. Closes the 'extract shared notebook-doc crate' item in #556.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracts the shared Automerge notebook document code into its own crate, eliminating the copy drift between
runtimed(daemon) andruntimed-wasm(frontend WASM bindings).What changed
crates/runtimed/src/notebook_doc.rs→crates/notebook-doc/src/lib.rsviagit mv(history preserved). The 833-line duplicate inruntimed-wasmis deleted.runtimednotebook-doc = { features = ["persistence"] }load_or_create,save_to_fileruntimed-wasmnotebook-doc(no features)Design decisions
persistencefeature gatesload_or_create,save_to_file,preserve_corrupt,notebook_doc_filename— these needstd::fs+logwhich are irrelevant for WASMStreamOutputStatemoved fromstream_terminal.rsto the shared crate (2-field struct, no external deps).stream_terminal.rsre-exports it.doc()/doc_mut()accessors onNotebookDocso consumers can extend via traits without forking the structTests
Relay simplification status
Audited
NotebookSyncHandlemethods — ALL are still live:send_request()— 13 call sites (kernel ops, save, env sync)get_cells()— format_cellupdate_source()— format_cell, initialize_notebook_syncadd_cell()— initialize_notebook_syncget_metadata()/set_metadata()— 6 call sites (runtime detection, trust, metadata sync)get_doc_bytes()/receive_frontend_sync_message()— Automerge relayOnly
delete_cell()on the handle has zero Tauri callers, but it's used byruntimed-py(Python agent API). Reducing the relay to pure forwarding would require migrating format_cell and initial population to go through Automerge sync instead of handle methods — a separate, more involved change.Closes the "extract shared notebook-doc crate" item in #556.