Skip to content

host: shorten a long message for the steward on character boundaries #2546

Closed

Description

@HugoXK

Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment on this issue.

Written-by: FlyBot Lead
Claimed-by: FlyBot Lead
Claim-Id: cfab780181c7410d941e05ea45bc8502
Branch: dev/5-steward-shorten-chars
Base: d400edb
At: 2026-11-05T14:36:23Z

Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment on this issue.

Written-by: FlyBot Lead

What happens

The long-message view the steward reads still cuts on UTF-16 units. core/src/host/steward.js:48-51:

function shorten(text) {
  if (text.length <= STEWARD_LINE_MAX) return text
  const head = Math.ceil((STEWARD_LINE_MAX * 2) / 3)
  return `${text.slice(0, head)}\n[… ${text.length - STEWARD_LINE_MAX} characters left out of this view …]\n${text.slice(head - STEWARD_LINE_MAX)}`
}

Two failures, both from slice/length counting units:

  • a cut at head (1000) or at head - STEWARD_LINE_MAX (the kept tail) can land between the halves of a surrogate pair, so the steward is handed a lone high or low surrogate — U+FFFD once encoded;
  • a message of 1,500 characters whose non-BMP characters make it more than 1,500 units is shortened even though it is inside its own limit, and the marker under-reports what was left out.

#1993 / #2000 fixed five bounds in core/src/host/ on cut() — one of them steward.js:148, the checkpoint note's quoted first line — but shorten() was not in that table, so this is the remaining site of the same family. core/src/shared/text-boundary.js already carries the rule this should follow (fits, cut, codePointStart, codePointEnd, and the #2321 note that the budget is counted in code points).

Reproduction

Clean base d400edb74798b71e233eccd46f221eaef782ff5d, only the new case added to core/test/steward.test.js:

# Subtest: a long message shortened for the steward cuts on characters, never inside one
not ok 11 - a long message shortened for the steward cuts on characters, never inside one
  error: |-
    a character at the cut stays whole
    false !== true
# tests 11 / # pass 10 / # fail 1

Two shapes: 'a'.repeat(999) + '🚀' + 'b'.repeat(800) (head cut at 1000 lands inside the emoji → lone high surrogate) and 'a'.repeat(1000) + '🚀' + 'b'.repeat(499) (tail cut lands on the low half; this one is only 1,500 characters and is shortened anyway). Run: node --test core/test/steward.test.js.

Expected

shorten() uses the shared rule: at most STEWARD_LINE_MAX characters (fits), both cuts land on code point boundaries (codePointStart / codePointEnd), and the marker counts the characters actually left out. The old "start + middle ellipsis + end" tests keep their assertions; stewardRequest and every other function in the file stay as they are.

Scope

  • core/src/host/steward.js — shorten() only (≈+10/−5).
  • core/test/steward.test.js — the new case (≈+17/−0), existing cases unchanged.
  • patches/ds-bot/0001-core-fixes.patch — regenerated by node scripts/ds-bot-patches.mjs generate (no hand edit). core/client.js, patches/ds-bot/0008* and the src/client/ mirrors are untouched.
  • changelog.d/<this issue>-steward-shorten-chars.fixed.md.

Tier: T2 (core/src/host/**, core/test/**).

Duplicate check

Checked before filing: #1993 (closed) / #2000 (merged, b048e26f509b) fixed five other bounds in this family — steward.js:148 included — and did not touch shorten(); search steward shorten → 0, steward in:title → 6 (all unrelated: parts retry, finish-chunk, condensation ratio), "characters left out of this view" → 0; no open PR touches core/src/host/steward.js.

Done when

The new case is red on the base and green with the fix, core/test/steward.test.js is 11/11, TZ=UTC ARCH_DOCS_BASE=d400edb7 npm run verify is exit 0, and patches check reports the regenerated 0001 series as clean.

Activity

  1. HugoXK commented on Nov 5, 2026

    @HugoXK
    ContributorAuthor

    Claim-Id: cfab780181c7410d941e05ea45bc8502
    Branch: dev/5-steward-shorten-chars
    Base: main (d400edb74798b71e233eccd46f221eaef782ff5d)

    Flight plan: one PR (Fixes #2546) from dev/5-steward-shorten-chars, ready, maintainer_can_modify: true, red-first evidence in the body. Bug, T2 (core/src/host/** + core/test/** + changelog.d/**). Remainder of the #1993/#2000 family: shorten() was not in that table.

  2. added a commit that references this issue on Nov 5, 2026
    2ec7faf
  3. HugoXK commented on Nov 5, 2026

    @HugoXK
    ContributorAuthor

    Release

    Written-by: FlyBot Lead
    Released: cfab780181c7410d941e05ea45bc8502
    Reason: merged to main via its PR (squash)
    At: 2026-11-05T15:35:50Z

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions