DSH / Atlas
2026-09-19proposedsimplification

Prune unused stream visibility helpers

精简未使用的流可见性辅助函数

The [compact Assistant stream implementation](../../../../packages/llm/llm/src/assistant-stream.ts) exports five visibility queries: `isVisibleChunk`, `chunkHasVisibleText`, `runFirstVisibleTime`, `assistantStreamHasVisibleContent`, and `assistantStreamHasVisibleText`. Repository searches find no production caller outside that family. Its other consumers are the [unit tests](../../../../packages/llm/llm/tests/assista

English

Problem

The compact Assistant stream implementation exports five visibility queries: isVisibleChunk, chunkHasVisibleText, runFirstVisibleTime, assistantStreamHasVisibleContent, and assistantStreamHasVisibleText. Repository searches find no production caller outside that family. Its other consumers are the unit tests, package documentation, and the record-reader reference. The package root and published ./assistant-stream entry expose the functions to external callers, whose usage this search cannot establish.

The retained first-token reader has current consumers in Session Stats and Trajectory. Their timing requirements do not require the separate whitespace-sensitive visibility classification.

Proposal

Remove the five exported visibility queries and their exclusive private helpers, hasNonWhitespace and blockIsVisible. This deletes approximately 77 source lines, including local documentation, without adding replacement machinery. Retain all first-token, raw-chunk, text-joining, and assembly readers, the accumulator, and validating expansion. Preserve the direct and library-backed LLM adapters and their extension APIs.

Remove dedicated visibility tests and only the obsolete assertions inside mixed reader tests. Keep the mixed fixtures and assertions that verify first-token timing, early exit, raw chunks, text joining, and assembly equivalence.

The package README owns compact-reader behavior: retained readers avoid materializing per-member expansions, and durable input still uses validating expansion. Preserve those constraints and the used readers. When implementing this proposal, update that README and the LLM subsystem page with their bilingual counterparts; archived records remain unchanged.

Alternatives considered

Keep a complete reader family for external consumers. This preserves convenient, tested visibility queries, but keeps public functions and dedicated tests without a demonstrated repository consumer. A named external requirement would justify retaining or reintroducing them.

Replace visibility queries with stream expansion. There is no production caller to migrate. Adding replacements would retain an unused API and introduce the allocations the record readers avoid.

Acceptance criteria

  • The five names disappear from source exports and current API documentation; no production caller gains an expansion or replacement visibility query.
  • Focused stream-reader, Session Stats, and Trajectory timing checks pass; mixed tests retain their unrelated assertions.
  • Typecheck, affected published-entry builds, and documentation checks pass. Session formats, model input, transcript content, and first-token timing remain unchanged.

Risks

This deliberately contracts exported pre-stable APIs. An external import may break even though repository consumers are absent. Refresh consumer evidence before implementation and assess any identified external requirement explicitly; do not claim ecosystem-wide non-use.

中文

问题

紧凑 Assistant 流实现导出五个可见性查询:isVisibleChunk、chunkHasVisibleText、runFirstVisibleTime、assistantStreamHasVisibleContent 和 assistantStreamHasVisibleText。仓库搜索未找到这组函数之外的生产调用方。其余消费方是单元测试、包文档和记录读取器参考。包根入口和发布的 ./assistant-stream 入口向外部调用方暴露这些函数;本次搜索无法确定外部使用情况。

保留的首 token 读取器已有 Session Stats 和 Trajectory 消费方。它们的计时要求不依赖单独区分空白文本的可见性分类。

提案

移除这五个导出的可见性查询及其专用私有辅助函数 hasNonWhitespace 和 blockIsVisible。这会删除约 77 行源码(含局部文档),无需新增替代机制。保留所有首 token、原始分片、文本拼接和组装读取器,以及累加器和带校验的展开操作。保留直接实现和基于库实现的两个 LLM(大语言模型)适配器及其扩展 API。

移除专门的可见性测试;混合读取器测试只删除过时断言。保留验证首 token 计时、提前退出、原始分片、文本拼接和组装等价性的混合 fixture(测试前置数据)与断言。

包 README负责紧凑读取器的行为:保留的读取器避免将逐成员展开结果实体化,持久化输入仍使用带校验的展开操作。保留这些约束和仍被使用的读取器。实施本提案时,更新该 README、LLM 子系统页面及其双语对侧;归档记录保持不变。

备选方案

为外部消费方保留完整的读取器组。 这能保留方便且经过测试的可见性查询,但也会在缺少已确认仓库消费方的情况下保留公共函数和专门测试。明确的外部需求可以成为保留或重新引入它们的理由。

用流展开替代可见性查询。 当前没有需要迁移的生产调用方。新增替代实现会继续保留未使用的 API,并引入记录读取器原本避免的分配开销。

验收标准

  • 源码导出和现行 API 文档中不再包含这五个名称;生产调用方不新增展开操作或替代可见性查询。
  • 针对流读取器、Session Stats 和 Trajectory 计时的检查通过;混合测试保留无关断言。
  • 类型检查、受影响发布入口的构建和文档检查通过。Session 格式、模型输入、transcript(文本记录)内容和首 token 计时保持不变。

风险

这会有意收缩导出的稳定前 API。即使仓库中没有消费方,外部导入仍可能失效。实施前重新核对消费方证据,并明确评估发现的外部需求;不得宣称整个生态均未使用这些函数。