🔒 fix(sdk): 表格 span 预算提升为文档级全局计数 (#458) - #461
Merged
Merged
Conversation
PR#428 的单表预算作用域错误:单表合法的 rowspan/colspan 展开可被任意 多张小表叠加,展开格总量仍无上界,OOM 路径依旧可达。 - buildTableGrid 返回本表格数,normalizeTablesHtml 维护跨表累计的 文档级预算(MAX_DOCUMENT_TABLE_CELLS=250k),超限表跳过归一化且 后续表全部跳过,展开物化总量从此有界 - 截断可观测:预算耗尽后向输出注入 [table span budget reached: N table(s) left unnormalized] 标记,流经 Turndown 成为可见文本, 不静默丢内容(跳过的表仍以原始形式进入转换) - 测试钉死:26 张合法小表组合反例(第 26 张被截+内容保留+标记)、 恰好填满预算的 25 张全展开边界、单表超限同样产生标记 Fixes #458 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
PR#428 为 HTML→Markdown 表格归一化加的展开预算作用域是 per-table 的:单张表的 rowspan/colspan 展开被限制在 25 万格内,但
normalizeTablesHtml对每张表独立施加预算,循环间无任何文档级累计。攻击页面只需包含任意多张合法小表(每张<td rowspan="100" colspan="100">约 52 字节、展开 1 万格),即可让展开格总量无上界,OOM 路径依旧可达。修复
buildTableGrid现在返回本表实际展开格数;normalizeTablesHtml在循环外维护跨表累计的documentCells,超过MAX_DOCUMENT_TABLE_CELLS(25 万,与单表上限同值)后当前表及后续所有表全部跳过归一化。任意输入的展开物化总量从此有硬上界。[table span budget reached: N table(s) left unnormalized]段落标记,流经 Turndown 成为最终 Markdown 中的可见文本。跳过的表仍以原始形式进入转换,内容不丢失——标记告知下游哪些表未做合并单元格展开。测试
新增
document-level span budget (#458)三用例:既有
( #303)预算测试不回归。验证
bun run --filter @lume/agent-sdk typecheck绿html-to-markdown.test.ts12/12、web-fetch-content/web-fetch-enhanced(🐛 fix(sdk): web 抓取/搜索域九项修复——span OOM、解压预算、reader 零联网、全链路可中断 #428 批次)与 scrapers 测试全绿Fixes #458
🤖 Generated with Claude Code