Skip to content

Test: add surrogate regression tests for the provider/MCP display-collapse paths (gap left by #856) #858

Description

@qwen-code-dev-bot

sourceType

source:self-discovery — undirected maintainer review pass. Follow-up to #856 (invocation display collapse made surrogate-safe), closing the regression-test gap for the provider/MCP sites.

sourceLinkOrEvidence

Concrete evidence on main @ 3bd091b. #856 made all three invocation-display collapse helpers surrogate-safe via safeCutEnd, but added surrogate regression tests only to tests/unit/tool-invocation.test.ts (3 tests tagged Issue #856). The provider and MCP sites are fixed but unprotected by any surrogate test:

  • src/provider-invocation.ts:513-520collapse uses safeCutEnd(oneLine, MAX_DISPLAY_OUTPUT) (line 518). tests/unit/provider-invocation.test.ts has a multi-byte test at line 276 (Issue #848), but that exercises the byte-cap path (invokeProvider/capOutput), NOT the display collapse used by formatProviderInvocation. No test drives an astral char across the 240-char display cap.
  • src/mcp-invocation.ts:622-629collapse uses safeCutEnd(oneLine, MAX_DISPLAY_OUTPUT) (line 627). tests/unit/mcp-invocation.test.ts has no surrogate/emoji/astral tests at all (grep for 🚀|surrogate|\ud800|astral|Issue #856 returns nothing).
  • Control: tests/unit/tool-invocation.test.ts has 3 Issue #856 tests covering surrogate-straddle, in-range, and long-ASCII truncation for the display collapse.

Minimal scenario: revert src/mcp-invocation.ts's collapse to raw oneLine.slice(0, MAX_DISPLAY_OUTPUT); formatMcpInvocation with an MCP result placing an astral char across the 240 cap then emits an unpaired surrogate and NO existing test fails (whereas the identical revert in tool-invocation.ts is caught by its #856 tests).

problemStatement

#856 hardened all three invocation-display collapse helpers, but only the tool-invocation site gained surrogate regression tests. The provider and MCP display-collapse paths are fixed in code yet have no test guarding them: a future revert or refactor of either collapse to a raw code-unit slice would reintroduce the unpaired-surrogate defect in Result: output without any failing test. The protection is asymmetric across three byte-identical helpers.

userValue

The provider Result: and MCP Result: one-line display truncations stay guarded against regression: any future change that re-splits a surrogate pair at the 240-char display cap fails CI immediately, matching the protection the tool-invocation path already has.

scope

  • Add surrogate regression tests for the display-collapse path in tests/unit/provider-invocation.test.ts (drive formatProviderInvocation via invokeProvider + the recording runner with an astral char straddling the 240 display cap) and in tests/unit/mcp-invocation.test.ts (same via invokeMcpServer/formatMcpInvocation).
  • Mirror the three Issue #856 cases from tool-invocation.test.ts (surrogate-straddle, in-range, long-ASCII) where the module's report shape allows.
  • Keep the existing byte-cap (#848) tests unchanged.

nonGoals

acceptanceCriteria

  • tests/unit/provider-invocation.test.ts has a display-collapse surrogate-straddle test asserting the Result: output has no unpaired surrogate (regex /[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/).
  • tests/unit/mcp-invocation.test.ts has a display-collapse surrogate-straddle test with the same assertion.
  • Each new test fails if the corresponding collapse is reverted to raw slice (red→green demonstrated).
  • In-range/long-ASCII cases pass and existing byte-cap tests remain green.

testPlan

Unit tests in tests/unit/provider-invocation.test.ts and tests/unit/mcp-invocation.test.ts: drive the format path with a result placing an astral character exactly across the 240 display cap, asserting no unpaired surrogate; add in-range and long-ASCII cases mirroring the tool-invocation #856 suite. Demonstrate red→green by temporarily reverting each collapse to raw slice.

dogfoodPlan

Run the provider-invocation and mcp-invocation unit suites (npx vitest run tests/unit/provider-invocation.test.ts tests/unit/mcp-invocation.test.ts) and confirm the new surrogate tests pass; temporarily revert one collapse to confirm the corresponding test fails, then restore.

riskAndSecurityNotes

Test-only change; no production code modified. No secrets/credentials/network action. The byte-cap tests and implementations are untouched.

duplicateSearchEvidence

parentChildRelationship

Standalone source:self-discovery Issue (not a child of any roadmap parent). Follow-up to #856, closing the provider/MCP regression-test gap.

dependencyOrder

No blocking dependencies; executable immediately (the collapse helpers are already fixed by #856; this adds tests only).

Activity

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

    agent-readyTrusted issue ready for autonomous implementationenhancementNew feature or requestpriority:p3Low priority: address when capacity allowssource:self-discoveryNormalized execution work from reproducible product dogfood

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions