Skip to content

The envelope slicer's cap leaves old joined envelopes unread; PASTED_BLOCK is super-linear on unclosed tags #734

Closed

Description

@SSFSKIM

What

Two leftovers of the work bound on the answer-envelope slicer (readAnswerEnvelopes, src/shared/engine/arrival.ts), both found by a review of the cap and read by the wave coordinator in the code.

  1. The cap leaves a whole message unread. A text that would cost more than MAX_ENVELOPE_CHECKS (64) whole-slice checks is left whole: no envelope is read from it. A message that joins several envelopes written by builds before the envelope stopped carrying the model's question text can reach the cap when those questions hold many lines that end in a code fence, because each such line costs one check. After a reload the requests those envelopes answered then draw as unanswered. No grant and no save decision depends on this reading (the grant reader does not use the slicer), so the cost is the drawing only, and only for old stored messages.

  2. PASTED_BLOCK is super-linear on unclosed opening tags. The pattern in src/shared/composer/pasted-content.ts pairs an opening tag with its closing tag through a lazy run and a back-reference; a text with many opening tags and no closing tag makes each opener scan to the text's end. The slicer no longer uses the pattern from the "Approve and retry" landing on (it uses the linear pastedBodies scan there). The other readers still use it on a user message's text: the transcript's splitPastedSegments (src/renderer/src/transcript/model/user-text.ts), the session index's title text (src/services/index/sessions.ts), the first message's text (src/renderer/src/sessions/first-message.ts) and the queue's entry text (src/renderer/src/composer/queue/entry-text.ts).

Direction

  • One linear reader of pasted segments (the pastedBodies scan, moved to the shared composer module) used by every reader above, with a work pin that would fail on the quadratic form and a differential test against PASTED_BLOCK on writer-made texts.
  • A slicer that finds an envelope's end in one forward pass (the strict line grammar of src/shared/maws/ask-strict.ts already does this for the current form), so the cap is no longer the only bound and old joined envelopes are read at any size.

Acceptance

  • A text of N opening paste tags with no closer costs work linear in its length in each reader named above (a counted pin).
  • A message joining old-form envelopes whose questions hold more than 64 fence lines reads every envelope, and its requests draw as answered after a reload.
  • Readings of writer-made messages are unchanged (the seeded corpus).

Activity

  1. added
    bug
    status:ready-for-implementer
    priority:P3
    status:in-progress
    and removed
    status:ready-for-implementer
    on Nov 16, 2026
  2. SSFSKIM commented on Nov 20, 2026

    @SSFSKIM
    OwnerAuthor

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

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

    @SSFSKIM
    OwnerAuthor

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

  5. 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:P3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions