Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions advisories/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion release-notes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
13 changes: 11 additions & 2 deletions src/advisory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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. */
Expand Down Expand Up @@ -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<string, unknown>;
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,
Expand Down
16 changes: 16 additions & 0 deletions src/text-safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Comment on lines +122 to +124
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`;
}
Comment on lines +125 to +129
11 changes: 9 additions & 2 deletions src/update-notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -118,8 +125,8 @@ export function parseReleaseNotesDoc(raw: unknown): { entries: ReleaseNoteEntry[
const e = item as Record<string, unknown>;
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;
Expand Down
Loading
Loading