Repository navigation
Conversation
…mote reason/summary acp_status prints an advisory's id + reason on its CRITICAL ADVISORY line and one line per release-note summary under CRITICAL UPDATE, straight into model context. Both parsers kept that text as-is apart from a trim: no length cap, line breaks preserved. Bound it where the documents are parsed (boundedLine in text-safe.ts): whitespace / control runs become one space, over-long text is cut on a code-point boundary and ends in an ellipsis. Entries are kept, never skipped. Caps: summary / summaryZh 400 (the producer-side contract), reason 500, id 80. Text inside the bounds is unchanged.
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
A moderate-severity flaw in boundedLine() allows non-positive cap values to produce output longer than the intended bound due to negative slicing via safePrefix(), indicating the function’s “bounded” contract isn’t reliably enforced.
2 open issues
What changed in this PR
Caps and flattens free-text fields from remote advisories and release-notes at parse time to prevent multi-line/overlong content from inflating model-context (acp_status) and other line-oriented outputs.
Changes:
- Add
boundedLine(text, cap)to normalize whitespace/control characters to single spaces and truncate on code-point boundaries with an ellipsis. - Apply bounded single-line normalization in advisory (
id,reason) and release-note (summary,summaryZh) parsers. - Update companion-doc READMEs to describe the enforced bounds/normalization and add regression tests covering truncation/flattening and
acp_statusline safety.
| File | Description |
|---|---|
| tests/remote-text-bounds.test.ts | Adds regression tests for boundedLine() behavior and ensures advisory/release-note parsing (and acp_status output shape) remains single-line and length-capped under hostile inputs. |
| src/update-notes.ts | Updates release-notes parsing to normalize and cap summary/summaryZh using the shared bounded single-line sanitizer. |
| src/text-safe.ts | Introduces boundedLine(text, cap) to collapse whitespace/control characters and truncate overly long strings safely with an ellipsis. |
| src/advisory.ts | Updates advisory document parsing to apply bounded single-line normalization to id and reason with explicit caps. |
| release-notes/README.md | Updates documentation to reflect that release-note summaries are consumed as single-line, capped text (including truncation behavior). |
| advisories/README.md | Updates documentation for advisory fields to describe client-side enforcement of single-line normalization and length limits. |
Review effort: Balanced
| export function boundedLine(text: string, cap: number): string { | ||
| const flat = text.replace(/[\s\x00-\x1f\x7f-\x9f]+/g, " ").trim(); | ||
| if (flat.length <= cap) return flat; | ||
| return `${safePrefix(flat, cap - 1).trimEnd()}\u2026`; | ||
| } |
| * one space; anything past `cap` code units is cut on a code-point boundary | ||
| * and marked with an ellipsis. Text already inside both bounds is returned | ||
| * unchanged apart from the outer trim callers did before. */ |
…g the client caps (ranxianglei#6306) The release-notes workflow already rejects summary/summaryZh over 400 chars at publish time; the advisories workflow had no length check at all, so an over-long reason/id would ship and only get truncated client-side (and the truncated id would then collide in the per-process warn dedupe). Same mechanism as the client caps in this PR — one producer-side mirror, same numbers (id 80, reason 500).
(ai: vllm-qwen/qwen3.8-27b) Duplicate screening: not a duplicate. Source issue #6306 is yours and this PR fixes it. PR #6156 touches the same feed fields but only Review (independent pass over the diff, not the issue's analysis)Direction (①): correct. The root cause is that the two parsers ( Regression review (②) — existing behaviors on the touched paths, each walked:
Code + tests (③④⑤⑤b): clean. Verification I ran (on head d5248f1, before my commit):
One addition I made (additive commit on your branch)Your "Not covered" note flagged that the advisories workflow has no producer-side length check — and you offered to add it. Same mechanism family as this PR (one issue = one scope), so instead of splitting it off I pushed it as a separate labeled commit on your branch:
If you'd rather keep the PR strictly client-side, say so and I'll drop that commit — but a publish-time failure is cheaper than a truncated banner, and the two workflows should be symmetric. 结构化八问
Verdict: mergeable — after CI re-runs green on the new head (7b7b337). It's an external PR and now also touches a CI publish workflow, so it stays at the human-review tier either way; nothing here blocks the owner's review. |
|
Landed via batch PR #6455 (merged) — closing as superseded. |


Fixes #6306
改了什么、为什么
acp_status是模型调用的工具,它打印的东西都是模型上下文。它的输出里有两部分来自 npm 伴生文档,原来除了trim()之外原样保留:CRITICAL ADVISORY (instance-level)那一行嵌着严重缺陷公告条目的id和reason(describeAdvisory);CRITICAL UPDATE READY / AVAILABLE下面,待更新区间里每个 release-notes 条目打印一行· <version> [tier] <summary>。这两个字段原来都没有长度上限,换行也保留。一个过长或多行的条目,就足以给每个调用
acp_status的会话塞进几万个字符,还能在CRITICAL …标题下另起新行,读起来像是代理自己写的。同样的字符串还会进到单行的日志警告和bili doctor报告里。本 PR 在解析两份文档的地方就把文字限住,所以每个使用方拿到的都是限过的值,
acp-status.ts本身没动:…;上限:
summary/summaryZh400(release-notes/README.md和 release-notes workflow 在生产端已经在执行的上限),reason500(advisories 文档原来没写上限;README 里的例子是 83 字符),id80(它和reason在同一行)。同一份输入分别在 master 和本分支上过两个解析函数(一段 30 000 字符、带两个换行的文字;一条公告,20 个 release-notes 条目):
describeAdvisoryacp_status会打印的区间行和 #6153 / PR #6156 的关系:那边为 web 面板的
innerHTML转义同样这些字段(只改src/web/client.ts);本 PR 是模型上下文和日志这一面。两者不碰同一批文件,谁也不替代谁。行为变化说明
reason超过 500 字符…acp_status、/acp面板、doctor、日志、web 横幅、/__bili/status里那一行有上限id超过 80 字符…reason同一行;它也是每个进程的警告去重键(前 80 字符相同的两个 id 会被当成同一个去重)summary/summaryZh超过 400 字符…affected、target、version、tier、minVersion、maxVersion、date、publishedAtacp_status不打印它们release-notes/package.json里现有的 17 个条目解析结果逐字节不变(最长的 summary 399 字符,没有换行,没有连续两个空格);advisories/package.json是空的。有一条测试钉住这一点。没有新增配置项,没有改 wire 协议或持久化,没有改 kernel。
改动
src/text-safe.ts:在已有的safePrefix旁边加boundedLine(text, cap)(截断用的就是safePrefix)。src/advisory.ts:parseAdvisoryDoc让id和reason过一遍它(CAP_ADVISORY_ID = 80,CAP_ADVISORY_REASON = 500)。src/update-notes.ts:parseReleaseNotesDoc让summary和summaryZh过一遍它(CAP_RELEASE_NOTE_SUMMARY = 400)。advisories/README.md、release-notes/README.md:字段表里写明客户端怎么处理过长或多行的文字(reason原来写的是 "shown verbatim")。tests/remote-text-bounds.test.ts:8 个用例。boundedLine本身(限制以内的不变、压平、在上限处截断、不拆开 surrogate 对);reason和id:限长、单行、条目保留、describeAdvisory里仍有升级命令;summary/summaryZh:限长、单行、条目保留;deepEqual;只有空白的字段仍然拒绝;handleAcpStatus:正好一行公告、区间里每个条目一行,每行都有上限,文档里的内容不会自己起一行。没覆盖的
reason/id的长度检查(release-notes workflow 有summary的)。CI 我没动;如果希望放在同一个 PR 里,我可以把这个检查加上。describeUpdateReady(/acp面板那一行)和 web 横幅用的是同样的解析结果,所以拿到的也是限过的文字;它们自己的代码没改。验证
acp_status那个);4 个反方向用例在两边都通过。加上修复后 8 个全部通过。npm run typecheck、check:unused-exports、check:test-import-graph、tools/check-architecture-docs.mjs、git diff --check:干净。dsh-native、web-sessions、runtime-info、preflight-nonstream-400-probe);后三个单独重跑时通过,dsh-native在同一环境下没改过的 master 上也是 72 通过 / 4 取消。8 个失败和没改过的 master 在这台机器上的失败相同(杀毒软件对回环 TLS 重新签名:3 个;我跑套件时套着的离线网络守卫:3 个;log-retention.test.ts里一个依赖本地时区的用例(本机不在 UTC):1 个;默认端口上已经有另一个 bili 实例在监听,issue3544-stale-proxy-rotation.test.ts里的健康探测连到了它:1 个)。advisory / update-notes 相关的文件(advisory、advisory-panel、advisory-endpoint-parity、issue2462-plugin-advisory、update-notes)不用改,都通过。src/advisory.ts时跑的 registry e2e 套件(ACP_TEST_REGISTRY=1)——它需要本地的 verdaccio,我没有搭;改动只限于parseAdvisoryDoc里的两个字符串字段。Linux / macOS 留给 CI。