Repository navigation
id(web): apply collab steps against a document model before storing - #16787
Merged
developing-today-fleet[bot] merged 1 commit intoNov 29, 2026
Merged
Conversation
…1618) The collab server now keeps a token model of the document — the base document plus every accepted step — and replays each step against it the way ProseMirror's Step.apply would, refusing what every receiving client would refuse: open depths that do not line up with the replaced range, joins between incompatible node types, rebuilt nodes whose content (or whose children's marks) their type does not admit, structure replaces over content, replaceAround gaps that are not flat or whose content does not fit, and attr/node-mark steps naming no node, a text node, or a wrongly-typed attr value. This completes the acceptance criteria of #1618: a step that does not parse or does not apply is refused with no Ack, nothing stored or broadcast, and the version frozen.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 40 minutes. View limit details
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. |
3 of 5 tasks
developing-today-fleet
Bot
deleted the
xaltha/1618-collab-apply-validation
branch
November 29, 2026 13:38
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.
Final stage of #1618 (slices 1–10 validated steps in isolation; this slice validates them against the document itself).
What
Documentnow carries aDocModel: a token model (open/close/text/leaf tokens with mark types) of the base document, evolved only by accepted steps.try_apply_stepsreplays each batch throughcheck_steps_in_doc, which runs the existing per-step validation and then applies the step to the model, mirroringprosemirror-transform'sStep.apply/prosemirror-model's replace machinery (oracle-verified against prosemirror-model 1.25.13 / transform 1.10.4, the versions the editor ships):compatibleContent) where slice chains meet document nodes — including the cross-depth case where the prepared slice joins through thefromside's ancestors — and fullvalidContentchecks (content expression with counts/order, plus child marks vs the parent's mark set) on every rebuilt node;structure: truereplaces refuse when the range contains content (contentBetweentoken rule);Slice.insertAt/canReplacefit of the gap content, then the composite replace;nodeAtexistence, text-node refusal, and declared-attr type checks (headinglevel/ ordered_listordernumeric, imagesrca string).A refused step stores nothing, broadcasts nothing, and leaves version, content size and model untouched — so acceptance criteria 1 and 2 of #1618 are now met: steps are validated against the server's actual document state (base doc + accepted steps), and a step that does not parse or does not apply is refused.
Tests
Eight new unit tests in
collab_steps.rsport the oracle probe cases (each refusal paired with valid controls), plus model-equality assertions for mark steps and step-by-step batch semantics. Existing collab suites unchanged.Closes #1618
{ "direct_parent": null, "links": [], "lineage": { "design": null, "roadmap_item": null, "priority": null }, "pm_meta": 1, "provenance": { "queue_id": null, "scheduled_start": null, "picked_up_at": null, "work_started_at": null, "created_at": "2026-11-29T13:12:39Z", "session_id": null, "lane": null, "host": "htch-runtime", "worktree": "/home/hatch/workspace/github-work/w0647-l03", "model": null, "lane_start_issues": [], "workspace_ref": { "kind": "worktree", "id": "/home/hatch/workspace/github-work/w0647-l03", "repo": "developing-today/code", "branch": "xaltha/1618-collab-apply-validation", "sha": "c7aaf47075cdaeb9fe9785b544e4ab4530fceb10" }, "auth_subject": "xaltha", "stamped_by": "fleet 0.1.0 (native)" } }Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.