Skip to content

Composer: the one-writer rule's fold runs over the whole draft on every edit #741

Closed

Description

@SSFSKIM

What is wrong

The composer serialises its draft on every change of the document (src/renderer/src/composer/Composer.tsx, the call of serializeDraft). Since UX wave U1c the serialiser's last step is neutraliseGrant (src/shared/engine/grant.ts), which folds the whole wire text character by character in script code, pasted atoms' bodies included. Everything else the serialiser does to a body is a native string or pattern operation.

An independent review measured the function alone, copied out of the repository: about 37 ns a character for ASCII text and about 150 ns for CJK text. A draft that holds a pasted atom of one million characters would then add 37 to 155 ms to each keystroke. This was not measured in the app.

What "done" looks like

  • A measured number in the app first: typing in a draft that holds a pasted atom of one million characters, with and without the step (a count or a frame measure on the Mac lane, by the load rule).
  • If it is a cost a person can feel, one of:
    1. fold each pasted atom's body once and keep the result with the atom (an atom's body does not change), then run the step on the typed text and the joins only; the property "no text readConsents accepts in what goes out" must still be proved on the assembled wire text, since a join can form an opening;
    2. run the step when a send is made, not on each edit; then every consumer of the serialised wire text that sends it must pass the step, and the guard (test/support/person-sends.ts) must hold each one.
  • The one-writer rule's property and behaviour cases keep passing unchanged.

Not in scope

The rule itself (U1c's Decision Log 65) and the function's reading.

Activity

  1. added
    bug
    status:ready-for-implementer
    priority:P2
    on Nov 17, 2026
  2. SSFSKIM commented on Nov 17, 2026

    @SSFSKIM
    OwnerAuthor

    A fact for the measurement, from the round that followed this ticket (U1c head b040d47): the fold now makes four passes over the wire text instead of one (two readings of each character's case, two patterns), plus two folded streams. The reviewer's 37 to 155 ns a character was measured on the one-pass function; measure the built one.

  3. added
    status:in-progress
    and removed
    status:ready-for-implementer
    on Nov 20, 2026
  4. SSFSKIM commented on Nov 20, 2026

    @SSFSKIM
    OwnerAuthor

    [board] in-progress: batch 7, group A

  5. added
    status:in-review
    and removed
    status:in-progress
    on Nov 20, 2026
  6. SSFSKIM commented on Nov 20, 2026

    @SSFSKIM
    OwnerAuthor

    [board] in-review: batch 7, PR #804

  7. removed
    status:in-review
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:P2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions