From d5248f138e00b0e13ecfb68b0e13da78d953cac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=99=B4=E7=8C=AB?= Date: Thu, 12 Nov 2026 05:44:53 +0900 Subject: [PATCH 1/2] fix(advisory,update-notes): cap length and collapse line breaks of remote 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. --- advisories/README.md | 4 +- release-notes/README.md | 2 +- src/advisory.ts | 13 +- src/text-safe.ts | 16 +++ src/update-notes.ts | 11 +- tests/remote-text-bounds.test.ts | 219 +++++++++++++++++++++++++++++++ 6 files changed, 258 insertions(+), 7 deletions(-) create mode 100644 tests/remote-text-bounds.test.ts diff --git a/advisories/README.md b/advisories/README.md index 7c95f0335d..394deb1bf2 100644 --- a/advisories/README.md +++ b/advisories/README.md @@ -22,10 +22,10 @@ Machine-readable critical-defect advisories for [billion-context](https://github | Field | Required | Meaning | |-------|----------|---------| -| `id` | yes | Stable identifier, e.g. `bc-2026-001`. Used to dedupe warnings per process; never reuse an id. | +| `id` | yes | Stable identifier, e.g. `bc-2026-001`. Used to dedupe warnings per process; never reuse an id. Keep it short: clients cut it at 80 chars. | | `affected` | yes | Semver range of broken versions, e.g. `>=0.1.155 <0.1.158`. | | `target` | yes | Exact version to force-install. May be OLDER than the user's current version (rollback semantics) when a newer release is also affected. Must be a published version of `billion-context`. | -| `reason` | yes | User-facing explanation, shown verbatim in the log warning and the web UI banner. Write it for end users, not developers. | +| `reason` | yes | User-facing explanation, shown in the log warning, the web UI banner, the `/acp` panel and `acp_status`. Write it for end users, not developers. One line, ≤500 chars: clients collapse line breaks into spaces and truncate anything longer (the advisory itself still applies). | | `publishedAt` | no | ISO timestamp. | ## Retiring an advisory diff --git a/release-notes/README.md b/release-notes/README.md index a39a5caeb5..6d15803e09 100644 --- a/release-notes/README.md +++ b/release-notes/README.md @@ -23,7 +23,7 @@ Companion package mechanics mirror `advisories/` (#1481): | version | yes | Exact released version (semver) | | date | no | `YYYY-MM-DD` release date | | tier | yes | `routine` (default) / `recommended` (restart soon, record-only) / `critical` (see below) | -| summary | yes | One user-meaningful line, ≤400 chars, model-written| +| summary | yes | One user-meaningful line, ≤400 chars, model-written. Clients enforce the same bound on read: line breaks collapse into spaces, longer text is truncated | | summaryZh | no | Chinese one-liner (≤400 chars) — zh-locale web surfaces pick it; `/acp` text stays English. Unset = every locale uses `summary` | | minVersion | no | Targeting: only RUNNING versions ≥ this (inclusive) see the entry. Unset = no floor | | maxVersion | no | Targeting: only RUNNING versions ≤ this (inclusive) see the entry. Unset = no ceiling | diff --git a/src/advisory.ts b/src/advisory.ts index b53100cb56..1bced997f2 100644 --- a/src/advisory.ts +++ b/src/advisory.ts @@ -33,6 +33,7 @@ import semver from "semver"; import { cacheDir } from "./paths.js"; import { log as loggerLog, type Logger } from "./logger.js"; import type { FetchOptions } from "./fetch-util.js"; +import { boundedLine } from "./text-safe.js"; import { CHECK_INTERVAL_MS, egressDispatcher, @@ -45,6 +46,14 @@ import { const ADVISORY_PACKAGE = "billion-context-advisories"; const SUPPORTED_SCHEMA = 1; +/** Client-side bounds for the two free-text fields of an entry. Both are + * printed on ONE line of acp_status (model context), the /acp panel, the + * doctor report and the log warning (describeAdvisory and the warn lines + * below), so they are flattened to a single line and capped when the document is + * parsed. Over-long text is TRUNCATED, never a reason to skip the entry: an + * advisory still has to force its target. */ +const CAP_ADVISORY_ID = 80; +const CAP_ADVISORY_REASON = 500; export type AdvisoryEntry = { /** Stable id, e.g. "bc-2026-001" — dedupes warnings per process. */ @@ -181,10 +190,10 @@ export function parseAdvisoryDoc(raw: unknown): { entries: AdvisoryEntry[]; erro for (const item of p.advisories) { if (typeof item !== "object" || item === null) continue; const e = item as Record; - const id = typeof e.id === "string" ? e.id.trim() : ""; + const id = typeof e.id === "string" ? boundedLine(e.id, CAP_ADVISORY_ID) : ""; const affected = typeof e.affected === "string" ? e.affected.trim() : ""; const target = typeof e.target === "string" ? e.target.trim() : ""; - const reason = typeof e.reason === "string" ? e.reason.trim() : ""; + const reason = typeof e.reason === "string" ? boundedLine(e.reason, CAP_ADVISORY_REASON) : ""; if (!id || !affected || !semver.valid(target) || !reason) continue; entries.push({ id, diff --git a/src/text-safe.ts b/src/text-safe.ts index b0b351184c..0f6cbbd0bb 100644 --- a/src/text-safe.ts +++ b/src/text-safe.ts @@ -111,3 +111,19 @@ export function scrubLoneSurrogateEscapes(text: string): string { export function scrubLoneSurrogatesOnWire(text: string): string { return scrubLoneSurrogateEscapes(scrubLoneSurrogates(text)); } + +/** One bounded display line out of text this process did not write (remote + * feed documents: an advisory `reason`, a release-note `summary`). Those + * strings are printed inside line-oriented surfaces the MODEL reads + * (acp_status sections) and inside single log lines, so a line break in the + * source would start a new, unattributed line there and an unbounded length + * would land in the context window as-is. Every run of whitespace and + * C0/C1 control characters (CR/LF/TAB, NEL, U+2028/U+2029 included) becomes + * 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. */ +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`; +} diff --git a/src/update-notes.ts b/src/update-notes.ts index 5586ffa4bb..dd7fc6c8db 100644 --- a/src/update-notes.ts +++ b/src/update-notes.ts @@ -32,12 +32,19 @@ import semver from "semver"; import { cacheDir } from "./paths.js"; import { log as loggerLog, type Logger } from "./logger.js"; import type { FetchOptions } from "./fetch-util.js"; +import { boundedLine } from "./text-safe.js"; import { CHECK_INTERVAL_MS, egressDispatcher, findInstallDir, readDiskVersion, registryUrlFor } from "./update.js"; const RELEASE_NOTES_PACKAGE = "billion-context-release-notes"; const SUPPORTED_SCHEMA = 1; /** Producer-side cap (release-notes/README): the doc keeps ~20 entries. */ const MAX_RELEASE_NOTES_ENTRIES = 20; +/** Producer-side cap (release-notes/README + the release-notes workflow): + * summary / summaryZh are one line of at most 400 chars. The client enforces + * the same bound when it parses the document, because acp_status prints + * every span summary as its own line into model context: line breaks are + * flattened and over-long text is truncated (the entry is kept). */ +const CAP_RELEASE_NOTE_SUMMARY = 400; type ReleaseTier = "routine" | "recommended" | "critical"; @@ -118,8 +125,8 @@ export function parseReleaseNotesDoc(raw: unknown): { entries: ReleaseNoteEntry[ const e = item as Record; const version = typeof e.version === "string" ? e.version.trim() : ""; const tier = e.tier === "recommended" || e.tier === "routine" || e.tier === "critical" ? e.tier : undefined; - const summary = typeof e.summary === "string" ? e.summary.trim() : ""; - const summaryZh = typeof e.summaryZh === "string" ? e.summaryZh.trim() : ""; + const summary = typeof e.summary === "string" ? boundedLine(e.summary, CAP_RELEASE_NOTE_SUMMARY) : ""; + const summaryZh = typeof e.summaryZh === "string" ? boundedLine(e.summaryZh, CAP_RELEASE_NOTE_SUMMARY) : ""; const minVersion = typeof e.minVersion === "string" ? e.minVersion.trim() : ""; const maxVersion = typeof e.maxVersion === "string" ? e.maxVersion.trim() : ""; if (!semver.valid(version) || tier === undefined || !summary) continue; diff --git a/tests/remote-text-bounds.test.ts b/tests/remote-text-bounds.test.ts new file mode 100644 index 0000000000..bd887c8203 --- /dev/null +++ b/tests/remote-text-bounds.test.ts @@ -0,0 +1,219 @@ +// Free text from the two npm companion documents (advisory `reason`, release-note +// `summary`) is printed on line-oriented surfaces the MODEL reads: acp_status +// puts the advisory on one "CRITICAL ADVISORY" line and every span summary on +// its own " · [tier] " line. The parsers used to keep that +// text as-is apart from a trim, so a document could add any number of extra +// lines under those headings and any number of characters to the context. +// These tests pin both directions: +// - over-long or multi-line text is flattened to one line and truncated when +// the document is parsed, and the entry itself is KEPT (an advisory still +// forces its target; a critical note still surfaces); +// - text already inside the bounds — including every entry this repo ships +// in advisories/ and release-notes/ — comes out byte-identical. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import type { Config, CoreMessage } from "acp-kernel"; +import { createCore, createInitialState, assignRefs, emptyRefMap, defaultConfig } from "acp-kernel"; +import type { Session } from "../src/session.ts"; +import { boundedLine } from "../src/text-safe.ts"; +import { parseAdvisoryDoc, describeAdvisory, _resetAdvisoryWatcherForTest, _setAdvisoryStateForTest } from "../src/advisory.ts"; +import { parseReleaseNotesDoc, _resetReleaseNotesWatcherForTest, _setReleaseNotesStateForTest } from "../src/update-notes.ts"; +import { VERSION } from "../src/version.ts"; +import semver from "semver"; + +const REASON_CAP = 500; +const SUMMARY_CAP = 400; +const ID_CAP = 80; +// Line breaks a display surface may honor: CR, LF, VT, FF, NEL, LS, PS. +const LINE_BREAK = /[\n\r\u000b\u000c\u0085\u2028\u2029]/; +const LINE_SPLIT = /\r\n|[\n\r\u000b\u000c\u0085\u2028\u2029]/; + +const HOSTILE = `first line of the text\r\n\nSECOND LINE that would sit under the heading on its own\u2028third\u2029fourth\u0085fifth\tsixth ${"x".repeat(30_000)}`; + +function advisoryDoc(advisories: unknown[]): unknown { + return { billionContextAdvisories: { schema: 1, advisories } }; +} + +function notesDoc(releases: unknown[]): unknown { + return { billionContextReleaseNotes: { schema: 1, releases } }; +} + +test("boundedLine: text inside the bounds is unchanged; breaks and control characters flatten; over-long text is cut with an ellipsis", () => { + assert.equal(boundedLine("breaks retries on 0.1.155–0.1.156; upgrade (#1844).", 500), "breaks retries on 0.1.155–0.1.156; upgrade (#1844)."); + assert.equal(boundedLine("中文一行,带标点。", 400), "中文一行,带标点。"); + assert.equal(boundedLine(" padded ", 10), "padded", "outer whitespace still trimmed, as before"); + assert.equal(boundedLine("a\r\nb\n\nc\td\u2028e\u2029f\u0085g\u0000h\u001bi", 100), "a b c d e f g h i"); + assert.equal(boundedLine(" \n\t ", 100), "", "whitespace-only stays empty so the required-field check still rejects it"); + + const exact = "y".repeat(400); + assert.equal(boundedLine(exact, 400), exact, "exactly at the cap: untouched"); + const cut = boundedLine("y".repeat(401), 400); + assert.equal(cut.length, 400); + assert.equal(cut, `${"y".repeat(399)}…`); + + // The cut never leaves half of a surrogate pair behind. + const emoji = boundedLine(`${"z".repeat(398)}😀tail`, 400); + assert.equal(emoji, `${"z".repeat(398)}…`); + assert.ok(!/[\ud800-\udbff](?![\udc00-\udfff])/.test(emoji)); +}); + +test("parseAdvisoryDoc: a multi-line, over-long reason becomes one bounded line and the entry is kept", () => { + const r = parseAdvisoryDoc(advisoryDoc([{ id: "bc-2026-001", affected: ">=0.1.155 <0.1.158", target: "0.1.157", reason: HOSTILE }])); + assert.equal(r.error, undefined); + assert.equal(r.entries.length, 1, "over-long text truncates; it does not drop the advisory"); + const e = r.entries[0]; + assert.equal(e.id, "bc-2026-001"); + assert.equal(e.affected, ">=0.1.155 <0.1.158"); + assert.equal(e.target, "0.1.157"); + assert.ok(e.reason.length <= REASON_CAP, `reason length ${e.reason.length}`); + assert.ok(!LINE_BREAK.test(e.reason), "reason is a single line"); + assert.ok(e.reason.startsWith("first line of the text SECOND LINE that would sit under the heading on its own third fourth fifth sixth xxx")); + assert.ok(e.reason.endsWith("…")); + + const line = describeAdvisory({ ...e, currentVersion: "0.1.156" }, undefined); + assert.ok(!LINE_BREAK.test(line), "describeAdvisory stays one line"); + assert.ok(line.length <= REASON_CAP + 200, `describeAdvisory length ${line.length}`); + assert.ok(line.includes("npm install -g billion-context@0.1.157"), "the upgrade command survives the truncation"); +}); + +test("parseAdvisoryDoc: the id is bounded the same way (it is printed on the same line)", () => { + const r = parseAdvisoryDoc(advisoryDoc([{ id: `bc-2026-002]\n\nNEW LINE ${"i".repeat(5000)}`, affected: ">=1.0.0", target: "1.0.1", reason: "r" }])); + assert.equal(r.entries.length, 1); + assert.ok(r.entries[0].id.length <= ID_CAP); + assert.ok(!LINE_BREAK.test(r.entries[0].id)); + assert.ok(r.entries[0].id.startsWith("bc-2026-002] NEW LINE iii")); +}); + +test("parseAdvisoryDoc: ordinary entries are byte-identical; whitespace-only fields are still rejected", () => { + const good = { id: "bc-2026-001", affected: ">=0.1.155 <0.1.158", target: "0.1.157", reason: "0.1.155–0.1.156 corrupts tool-call arguments on retry; upgrade to 0.1.157 or later.", publishedAt: "2026-09-27T12:00:00Z" }; + assert.deepEqual(parseAdvisoryDoc(advisoryDoc([good])).entries, [good]); + const atCap = { id: "i".repeat(ID_CAP), affected: ">=1.0.0", target: "1.0.1", reason: "r".repeat(REASON_CAP) }; + assert.deepEqual(parseAdvisoryDoc(advisoryDoc([atCap])).entries, [atCap], "exactly at the caps: untouched"); + const blank = parseAdvisoryDoc(advisoryDoc([{ id: "x", affected: ">=1.0.0", target: "1.0.1", reason: "\n \t" }, { id: "\r\n", affected: ">=1.0.0", target: "1.0.1", reason: "r" }])); + assert.deepEqual(blank.entries, []); + assert.match(blank.error ?? "", /no valid advisories/); +}); + +test("parseReleaseNotesDoc: multi-line, over-long summary / summaryZh become one bounded line each and the entry is kept", () => { + const r = parseReleaseNotesDoc(notesDoc([{ version: "0.1.180", date: "2026-10-02", tier: "critical", summary: HOSTILE, summaryZh: `第一行\n第二行${"字".repeat(5000)}`, minVersion: "0.1.100" }])); + assert.equal(r.error, undefined); + assert.equal(r.entries.length, 1, "over-long text truncates; it does not drop the note"); + const e = r.entries[0]; + assert.equal(e.version, "0.1.180"); + assert.equal(e.tier, "critical"); + assert.equal(e.minVersion, "0.1.100"); + assert.ok(e.summary.length <= SUMMARY_CAP, `summary length ${e.summary.length}`); + assert.ok(!LINE_BREAK.test(e.summary)); + assert.ok(e.summary.startsWith("first line of the text SECOND LINE")); + assert.ok(e.summary.endsWith("…")); + assert.ok(e.summaryZh !== undefined && e.summaryZh.length <= SUMMARY_CAP); + assert.ok(!LINE_BREAK.test(e.summaryZh ?? "")); + assert.ok((e.summaryZh ?? "").startsWith("第一行 第二行字字")); +}); + +test("parseReleaseNotesDoc: ordinary entries are byte-identical; a whitespace-only summary is still rejected", () => { + const good = { version: "0.1.180", date: "2026-10-02", tier: "critical", summary: "OpenCode WebSocket traffic is intercepted again — compression and usage stats no longer silently no-op on OpenCode ≥ 2.0.20 (#1844).", summaryZh: "OpenCode 的 WebSocket 流量重新被接管(#1844)。" }; + assert.deepEqual(parseReleaseNotesDoc(notesDoc([good])).entries, [good]); + const atCap = { version: "0.1.181", tier: "routine", summary: "s".repeat(SUMMARY_CAP), summaryZh: "字".repeat(SUMMARY_CAP) }; + assert.deepEqual(parseReleaseNotesDoc(notesDoc([atCap])).entries, [atCap], "exactly at the producer-side cap: untouched"); + const blank = parseReleaseNotesDoc(notesDoc([{ version: "0.1.182", tier: "routine", summary: " \n\t " }])); + assert.deepEqual(blank.entries, []); + assert.match(blank.error ?? "", /no valid release-note entries/); +}); + +test("the documents this repo publishes parse unchanged (no shipped entry is touched by the bounds)", () => { + const notesRaw = JSON.parse(readFileSync(new URL("../release-notes/package.json", import.meta.url), "utf8")) as { billionContextReleaseNotes: { releases: Array> } }; + const shipped = notesRaw.billionContextReleaseNotes.releases; + const parsed = parseReleaseNotesDoc(notesRaw); + assert.equal(parsed.error, undefined); + assert.equal(parsed.entries.length, shipped.length); + for (let i = 0; i < shipped.length; i++) { + assert.equal(parsed.entries[i].summary, shipped[i].summary, `release-notes entry ${String(shipped[i].version)}: summary`); + assert.equal(parsed.entries[i].summaryZh, shipped[i].summaryZh, `release-notes entry ${String(shipped[i].version)}: summaryZh`); + } + + const advRaw = JSON.parse(readFileSync(new URL("../advisories/package.json", import.meta.url), "utf8")) as { billionContextAdvisories: { advisories: Array> } }; + const advShipped = advRaw.billionContextAdvisories.advisories; + const adv = parseAdvisoryDoc(advRaw); + assert.equal(adv.error, undefined); + assert.equal(adv.entries.length, advShipped.length); + for (let i = 0; i < advShipped.length; i++) { + assert.equal(adv.entries[i].id, advShipped[i].id); + assert.equal(adv.entries[i].reason, advShipped[i].reason); + } +}); + +function makeCtx(): { core: ReturnType; config: Config; messages: CoreMessage[]; session: Session; log: (m: string) => void } { + const messages: CoreMessage[] = []; + for (let i = 1; i <= 12; i++) messages.push({ id: `raw_${i}`, role: i % 2 === 1 ? "user" : "assistant", contentType: "text", text: "x".repeat(5000) }); + const ctx = { + core: createCore(), + config: defaultConfig(200000), + messages, + session: { + id: "remote-text-bounds-test", + meta: {}, + stats: { requests: 0, tokensSaved: 0, inputTokens: 0, cachedTokens: 0, outputTokens: 0, cacheSamples: 0, lastInputTokens: 15000, compressCreditTokens: 0, contextTokens: 0, retrieveCalls: 0, retrieveHits: 0, retrieveMisses: 0, storedBytes: 0, storeBytesSaved: 0, rangeRestores: 0 }, + metadata: {}, + state: createInitialState(), + createdAt: Date.now(), + lastSeen: Date.now(), + blockContents: new Map(), + inFlight: 0, + persisted: false, + pendingRetrievals: [], + } as Session, + log: () => {}, + }; + ctx.session.state.messageRefs = assignRefs(ctx.messages, { existing: emptyRefMap(), nextIndex: 0 }).map; + return ctx; +} + +test("acp_status: a hostile document adds exactly one advisory line and one line per span entry, each bounded", async () => { + _resetAdvisoryWatcherForTest(); + _resetReleaseNotesWatcherForTest(); + const { handleAcpStatus } = await import("../src/acp-status.ts"); + const running = semver.valid(VERSION) ?? "0.0.1"; + const next = semver.inc(running, "patch") ?? "0.0.2"; + const next2 = semver.inc(next, "patch") ?? "0.0.3"; + try { + const ctx = makeCtx(); + const clean = handleAcpStatus({}, ctx).text; + assert.ok(!clean.includes("CRITICAL ADVISORY") && !clean.includes("CRITICAL UPDATE")); + const cleanLines = clean.split(LINE_SPLIT).length; + + // Everything below goes through the real parsers, the way the two + // watchers feed the state the surface reads. + const adv = parseAdvisoryDoc(advisoryDoc([{ id: "bc-2026-001", affected: ">=0.0.0", target: "0.1.157", reason: HOSTILE }])); + const notes = parseReleaseNotesDoc(notesDoc([ + { version: next2, tier: "routine", summary: HOSTILE }, + { version: next, tier: "critical", summary: HOSTILE }, + ])); + _setAdvisoryStateForTest({ active: { ...adv.entries[0], currentVersion: running } }); + _setReleaseNotesStateForTest({ entries: notes.entries, diskVersion: next2 }); + + const text = handleAcpStatus({}, ctx).text; + const lines = text.split(LINE_SPLIT); + const advLines = lines.filter((l) => l.includes("CRITICAL ADVISORY (instance-level)")); + assert.equal(advLines.length, 1); + assert.ok(advLines[0].length <= REASON_CAP + 500, `advisory line length ${advLines[0].length}`); + assert.ok(advLines[0].includes("first line of the text SECOND LINE"), "the flattened text sits on the advisory line itself"); + assert.ok(advLines[0].endsWith("Live state: the advisory field of GET /__bili/status."), "the fixed tail of the line is still there"); + + const spanLines = lines.filter((l) => l.startsWith(" · ")); + assert.equal(spanLines.length, 2, "one line per span entry"); + for (const l of spanLines) assert.ok(l.length <= SUMMARY_CAP + 60, `span line length ${l.length}`); + assert.ok(text.includes("CRITICAL UPDATE READY (instance-level)")); + + // Section arithmetic: blank + advisory line, blank + headline + 2 span + // lines + live-state line. Nothing from the document starts a line of + // its own. + assert.equal(lines.length, cleanLines + 2 + 5); + assert.ok(!lines.some((l) => l.startsWith("SECOND LINE")), "document text never starts a line"); + assert.ok(text.length < clean.length + 3000, `section growth ${text.length - clean.length}`); + } finally { + _resetAdvisoryWatcherForTest(); + _resetReleaseNotesWatcherForTest(); + } +}); From 7b7b337e4bff9a383a72c3888100558f0b7626da Mon Sep 17 00:00:00 2001 From: ci-check Date: Thu, 12 Nov 2026 18:40:09 +0800 Subject: [PATCH 2/2] fix(advisories): cap id/reason length in publish validation, mirroring the client caps (#6306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- .github/workflows/advisories.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/advisories.yml b/.github/workflows/advisories.yml index 6c8edbcff9..cf61b3ffce 100644 --- a/.github/workflows/advisories.yml +++ b/.github/workflows/advisories.yml @@ -40,6 +40,17 @@ jobs: console.error('advisory entry missing required fields:', JSON.stringify(a)); process.exit(1); } + // #6306: producer-side mirror of the client caps (src/advisory.ts + // CAP_ADVISORY_ID / CAP_ADVISORY_REASON) — the client truncates, + // but a publish-time failure is cheaper than a truncated banner. + if (String(a.id).length > 80) { + console.error('advisory', a.id, ': id too long (' + String(a.id).length + ' chars, cap 80)'); + process.exit(1); + } + if (String(a.reason).length > 500) { + console.error('advisory', a.id, ': reason too long (' + String(a.reason).length + ' chars, cap 500)'); + process.exit(1); + } try { new semver.Range(a.affected); } catch {