From 6b8113e9510883bce402d258bcbf201cc96f9c5d Mon Sep 17 00:00:00 2001 From: ci-check Date: Mon, 26 Oct 2026 01:35:30 +0800 Subject: [PATCH 1/2] fix(#4688): recognize antigravity UA on the conflict surfaces Antigravity is a known bili lane (launcher, #3129/#2115) but its wire identity was never resolved server-side: sessions carrying conflict events showed clients: (none resolved) and only the generic remediation hint. Add the evidence-backed UA predicate (antigravity/hub/, observed shape v2.26.0 Windows via #4688) mirroring the codex pattern: sniffScanClient recognizes it with no scannable registry (closed binary, #1043), conflictClientOf normalizes recorded UA hints back to "antigravity", and the conflict surfaces (acp_status / web banner / launcher) get a dedicated one-line remediation instead of the generic fallback. Display-only: no wire or compression semantics change. --- src/conflict-watch.ts | 10 +++++++--- src/thirdparty-scan.ts | 21 ++++++++++++++++++--- src/web/client.ts | 1 + src/web/i18n.ts | 2 ++ tests/conflict-remediation.test.ts | 16 ++++++++++++++-- tests/issue1206-thirdparty-scan.test.ts | 12 +++++++++++- 6 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/conflict-watch.ts b/src/conflict-watch.ts index 83eb287ac3..ecc26f5445 100644 --- a/src/conflict-watch.ts +++ b/src/conflict-watch.ts @@ -11,7 +11,7 @@ import { markDirty, type Session } from "./session.js"; import { isCodexClient } from "./codex-compact.js"; -import { isDisplayOnlyConflictDetail, isSiblingConflictDetail } from "./thirdparty-scan.js"; +import { isAntigravityClient, isDisplayOnlyConflictDetail, isSiblingConflictDetail } from "./thirdparty-scan.js"; type ConflictKind = "third-party-plugin" | "unannounced-rewrite" | "orphan-reap" | "native-compaction" | "native-compaction-inferred" | "identity-orphan" | "id-churn-adoption"; @@ -106,8 +106,9 @@ export function dshNativeCompactionWitness(session: Session, fingerprint?: Rewri // Identity is already recorded at request time (#1426): pluginAgent wins when // present ("mcp" is not a client name — MCP evidence flip, #760b — so fall // through), then clientHint, which is either an exact sniffScanClient value or -// a UA truncation; codex UA shapes normalize back to "codex" and clean single -// tokens pass through as-is (unknown ones simply get the generic hint). +// a UA truncation; codex/antigravity UA shapes normalize back to their lane +// names (#2219/#4688) and clean single tokens pass through as-is (unknown ones +// simply get the generic hint). export function conflictClientOf(session: Session): string | undefined { const pa = session.metadata.pluginAgent; if (typeof pa === "string" && pa.length > 0 && pa !== "mcp") return pa; @@ -115,6 +116,7 @@ export function conflictClientOf(session: Session): string | undefined { if (typeof hint !== "string" || !hint) return undefined; if (/^[a-z][a-z0-9-]*$/.test(hint)) return hint; if (isCodexClient({ "user-agent": hint })) return "codex"; + if (isAntigravityClient({ "user-agent": hint })) return "antigravity"; return undefined; } @@ -138,6 +140,8 @@ export function conflictRemediation(client: string | undefined): string { case "pi": case "omp": return "the bili extension cancels the client's native auto-compaction while it carries the conversation — seeing this suggests missing carriage evidence or an old version; report client + bili version"; + case "antigravity": + return "Antigravity manages its own context window and periodically re-slices history without telling bili — expected lane behavior, not double compression; folded content stays offline-recoverable (export --full), but start a new task/session when you need the pruned context back"; default: return "disable the client's own auto-compaction (or route this session around bili), then start a fresh session — the ledger is per-session, so old entries clear with the old session"; } diff --git a/src/thirdparty-scan.ts b/src/thirdparty-scan.ts index 6fc46fce44..bd7b30ce4b 100644 --- a/src/thirdparty-scan.ts +++ b/src/thirdparty-scan.ts @@ -126,10 +126,24 @@ export function conflictScanEnabled(env: NodeJS.ProcessEnv = process.env): boole return !(v === "0" || v === "false"); } +/** #4688: Google Antigravity IDE wire profile — UA shape observed in the wild + * (v2.26.0, Windows session through bili): "antigravity/hub/ (aidev_client; …)". + * Prefix-anchored and case-insensitive, mirroring isCodexClient's prefix style; + * deliberately NOT a bare-token match — a UA merely mentioning antigravity + * elsewhere must not inherit this lane's identity. */ +export function isAntigravityClient(headers: Record): boolean { + const ua = headers["user-agent"]; + if (!ua) return false; + const s = Array.isArray(ua) ? ua[0] : ua; + if (typeof s !== "string") return false; + return /^antigravity\//i.test(s); +} + /** Identify the requesting client from wire headers so a standalone proxy - * (no x-bili-plugin header) can still scan the right registry. Codex is - * recognized but returns undefined — it has no scannable plugin registry - * here, and its compaction paths are already intercepted/budget-aligned. */ + * (no x-bili-plugin header) can still scan the right registry. Codex and + * Antigravity are recognized but return undefined — closed binaries with no + * scannable plugin registry (#1043); their identity resolves on the conflict + * surfaces via conflictClientOf instead (#2219/#4688). */ export function sniffScanClient(headers: Record): ScanClient | undefined { const h = (name: string): string | undefined => { const v = headers[name]; @@ -138,6 +152,7 @@ export function sniffScanClient(headers: Record> = { "conflict.hint.codex": "codex:bili 默认拦截原生压缩(BILI_CODEX_COMPACT=intercept)——若你设了 pass,去掉该覆盖即可;否则请报告你的 bili 版本", "conflict.hint.pi": "pi:bili 扩展在接管会话时会自动取消客户端原生自动压缩——仍出现说明缺少接管证据或版本过旧,请报告客户端与 bili 版本", "conflict.hint.omp": "omp:bili 扩展在接管会话时会自动取消客户端原生自动压缩——仍出现说明缺少接管证据或版本过旧,请报告客户端与 bili 版本", + "conflict.hint.antigravity": "antigravity:客户端自行管理上下文窗口并会周期性重切历史(bili 无法阻止)——属该车道预期行为,不是双重压缩;被裁掉跨度上的折叠内容可离线找回(export --full),需要被裁剪的上下文时请开新任务/新会话", "conflict.hint.generic": "关闭客户端自身的自动压缩(或让本会话绕过 bili),然后开新会话——台账按会话隔离,旧记录随旧会话消失", "conflict.hint_more": "另有 {n} 个客户端,详见下方 Sessions 页", "conflict.docs": "完整矩阵:CONFIGURATION.md「Detecting other compression plugins (#1206)」", @@ -839,6 +840,7 @@ export const MESSAGES: Record> = { "conflict.hint.codex": "codex: bili intercepts native compaction by default (BILI_CODEX_COMPACT=intercept) — if you set pass, remove the override to stop; otherwise report your bili version", "conflict.hint.pi": "pi: the bili extension cancels the client's native auto-compaction while it carries the conversation — seeing this suggests missing carriage evidence or an old version; report client + bili version", "conflict.hint.omp": "omp: the bili extension cancels the client's native auto-compaction while it carries the conversation — seeing this suggests missing carriage evidence or an old version; report client + bili version", + "conflict.hint.antigravity": "antigravity: the client manages its own context window and periodically re-slices history (bili cannot stop it) — expected lane behavior, not double compression; folded content stays offline-recoverable (export --full), but start a new task/session when you need the pruned context back", "conflict.hint.generic": "disable the client's own auto-compaction (or route this session around bili), then start a fresh session — the ledger is per-session, so old entries clear with the old session", "conflict.hint_more": "{n} more client(s) — see the Sessions page below", "conflict.docs": "full matrix: CONFIGURATION.md → \"Detecting other compression plugins (#1206)\"", diff --git a/tests/conflict-remediation.test.ts b/tests/conflict-remediation.test.ts index aa4c486b65..a593497b17 100644 --- a/tests/conflict-remediation.test.ts +++ b/tests/conflict-remediation.test.ts @@ -58,6 +58,14 @@ test("conflictClientOf: codex UA truncations normalize to codex, look-alikes do assert.equal(conflictClientOf(makeSession("f", { clientHint: "claude" })), "claude"); }); +test("conflictClientOf: antigravity UA shapes normalize to antigravity, look-alikes do not (#4688)", () => { + assert.equal(conflictClientOf(makeSession("a", { clientHint: "antigravity/hub/2.26.0 (aidev_client; os_type=windows; arch=amd64; cl=1005016104)" })), "antigravity"); + assert.equal(conflictClientOf(makeSession("b", { clientHint: "Antigravity/hub/9.9.9" })), "antigravity"); + // prefix-anchored only — a mention elsewhere in the UA is not this lane + assert.equal(conflictClientOf(makeSession("c", { clientHint: "vendor/antigravity-wrapper/1.0" })), undefined); + assert.equal(conflictClientOf(makeSession("d", { clientHint: "Mozilla/5.0 antigravity-fan-club" })), undefined); +}); + test("conflictRemediation: one line per known client, generic fallback for the rest (#2219)", () => { const oc = conflictRemediation("opencode"); assert.ok(oc.includes('"compaction": { "auto": false }'), oc); @@ -71,12 +79,15 @@ test("conflictRemediation: one line per known client, generic fallback for the r assert.ok(!cx.includes("never transits"), "#3008: the inline auto-compact DOES transit as an ordinary turn — the old copy was false"); assert.equal(conflictRemediation("pi"), conflictRemediation("omp"), "pi and omp share the carriage-evidence hint"); assert.ok(conflictRemediation("pi").includes("report client + bili version")); + const ag = conflictRemediation("antigravity"); + assert.ok(ag.includes("not double compression"), ag); + assert.ok(ag.includes("export --full"), ag); const gen = conflictRemediation(undefined); assert.ok(gen.includes("fresh session"), gen); for (const c of ["dsh", "kimi", "hermes", "zcode", "gemini-cli"]) { assert.equal(conflictRemediation(c), gen, `${c} falls back to the generic hint`); } - for (const c of ["opencode", "claude", "codex", "pi", "omp", undefined]) { + for (const c of ["opencode", "claude", "codex", "pi", "omp", "antigravity", undefined]) { assert.ok(!conflictRemediation(c).includes("\n"), "hints render inline — one line only"); } }); @@ -124,6 +135,7 @@ test("i18n: every conflict.hint.* key exists in BOTH locales; server map and web "conflict.hint.codex", "conflict.hint.pi", "conflict.hint.omp", + "conflict.hint.antigravity", "conflict.hint.generic", "conflict.hint_more", "conflict.docs", @@ -134,7 +146,7 @@ test("i18n: every conflict.hint.* key exists in BOTH locales; server map and web assert.ok(typeof zh === "string" && zh.length > 0, `zh-CN missing ${k}`); assert.ok(typeof en === "string" && en.length > 0, `en missing ${k}`); } - for (const c of ["opencode", "claude", "codex", "pi", "omp"]) { + for (const c of ["opencode", "claude", "codex", "pi", "omp", "antigravity"]) { assert.ok(MESSAGES["zh-CN"][`conflict.hint.${c}`] && MESSAGES["en"][`conflict.hint.${c}`], `drift: ${c} missing from i18n`); } }); diff --git a/tests/issue1206-thirdparty-scan.test.ts b/tests/issue1206-thirdparty-scan.test.ts index 92007254ef..6fcf883edf 100644 --- a/tests/issue1206-thirdparty-scan.test.ts +++ b/tests/issue1206-thirdparty-scan.test.ts @@ -8,7 +8,7 @@ process.env.NODE_ENV = "test"; import { createInitialState } from "acp-kernel"; import type { Session } from "../src/session.ts"; -import { clearScanCache, conflictScanEnabled, isDesignBenign, isDisplayOnlyConflictDetail, isKnownDisplayOnlyPlugin, isOpencodeAcpEntry, isSiblingConflictDetail, parsePluginConflictDetail, scanClientPlugins, sniffScanClient, type ThirdPartyFinding } from "../src/thirdparty-scan.js"; +import { clearScanCache, conflictScanEnabled, isAntigravityClient, isDesignBenign, isDisplayOnlyConflictDetail, isKnownDisplayOnlyPlugin, isOpencodeAcpEntry, isSiblingConflictDetail, parsePluginConflictDetail, scanClientPlugins, sniffScanClient, type ThirdPartyFinding } from "../src/thirdparty-scan.js"; import { CONFLICT_LEDGER_MAX, conflictEventsOf, formatConflictSection, recordConflict, summarizeConflicts } from "../src/conflict-watch.js"; import { resolveHermesHome, resolveKimiHome, resolveOmpHome, resolvePiHome } from "../src/client-config.js"; import { SessionStore, _setStoreForTest } from "../src/persist.js"; @@ -70,12 +70,22 @@ test("sniffScanClient identifies clients from wire headers", () => { assert.equal(sniffScanClient({ "x-claude-code-session-id": "abc" }), "claude"); assert.equal(sniffScanClient({ "user-agent": "codex_cli_rs/0.50.0" }), undefined); assert.equal(sniffScanClient({ "user-agent": "codex desktop/1.0" }), undefined); + // antigravity: recognized but no scannable registry — same contract as codex (#4688) + assert.equal(sniffScanClient({ "user-agent": "antigravity/hub/2.26.0 (aidev_client; os_type=windows)" }), undefined); assert.equal(sniffScanClient({ "x-opencode-session": "ses_123" }), "opencode"); assert.equal(sniffScanClient({ "x-session-affinity": "ses_abc" }), "opencode"); assert.equal(sniffScanClient({ "x-session-affinity": "not-a-session" }), undefined); assert.equal(sniffScanClient({}), undefined); }); +test("isAntigravityClient matches the antigravity/hub/ UA prefix only (#4688)", () => { + assert.equal(isAntigravityClient({ "user-agent": "antigravity/hub/2.26.0 (aidev_client; os_type=windows; arch=amd64; cl=1005016104)" }), true); + assert.equal(isAntigravityClient({ "user-agent": "Antigravity/hub/1.0" }), true); + assert.equal(isAntigravityClient({ "user-agent": "my-antigravity-tool/2.0" }), false); + assert.equal(isAntigravityClient({}), false); + assert.equal(isAntigravityClient({ "user-agent": [] }), false); +}); + test("opencode scan: known conflict + keyword entries, self/context7 skipped", () => { clearScanCache(); const root = tmp("bili-1206-oc-"); From 1319b6e4eaf2460665d233d205aaef5f6a8b2673 Mon Sep 17 00:00:00 2001 From: ci-check Date: Fri, 13 Nov 2026 09:40:40 +0800 Subject: [PATCH 2/2] fix: resolve antigravity in the client-ua-registry family mirror (#4688) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit clientFamilyOf (client-ua-registry.ts) is documented as mirroring conflictClientOf's resolution ladder, but only handled the codex UA shape. Now that conflictClientOf recognizes antigravity (#4758), the mirror was out of sync: antigravity UAs stayed bucketed under "other" in the diagnostics "observed client user-agents" section. Add the antigravity arm (mirroring the codex line) plus a positive+negative test row. Display-only — no wire or compression semantics change; the observed-ua line is strictly more accurate (family label "other" -> "antigravity"). --- src/client-ua-registry.ts | 9 +++++---- tests/issue4649-conflict-report-client-coverage.test.ts | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/client-ua-registry.ts b/src/client-ua-registry.ts index 48910b16d2..bde7261b0a 100644 --- a/src/client-ua-registry.ts +++ b/src/client-ua-registry.ts @@ -18,7 +18,7 @@ // at ingest (UA_MAX_CHARS) so one hostile UA cannot bloat the pasteable blob. import { isCodexClient } from "./codex-compact.js"; -import { sniffScanClient } from "./thirdparty-scan.js"; +import { isAntigravityClient, sniffScanClient } from "./thirdparty-scan.js"; // Read directly (wire literal) instead of via plugin.ts — same discipline as // codex-compact.ts / session-id.ts: importing plugin.ts back into the request @@ -43,9 +43,9 @@ function headerString(headers: Record, na } /** Client family for UA bookkeeping — mirrors conflictClientOf's resolution - * ladder (declared plugin agent > header sniff > codex UA shape) keyed off - * the raw request headers. "mcp" is not a client name (MCP evidence flip, - * #760b), so it falls through like in conflict-watch. */ + * ladder (declared plugin agent > header sniff > codex/antigravity UA shape) + * keyed off the raw request headers. "mcp" is not a client name (MCP evidence + * flip, #760b), so it falls through like in conflict-watch. */ export function clientFamilyOf(headers: Record): string { const agent = headerString(headers, BILI_PLUGIN_MARKER); if (agent && agent !== "mcp") return agent; @@ -53,6 +53,7 @@ export function clientFamilyOf(headers: Record { assert.equal(clientFamilyOf({ "user-agent": "Codex Desktop/9.9.9" }), "codex", "capitalized variant prefix"); assert.equal(clientFamilyOf({ "user-agent": "vendor/tool codex_foo/1.0" }), "codex", "token-level lenient fallback (#645)"); assert.equal(clientFamilyOf({ "user-agent": "vendor/codex-wrapper" }), "other", "mid-token codex mention is NOT codex (#1641)"); + assert.equal(clientFamilyOf({ "user-agent": "antigravity/hub/2.26.0 (aidev_client; os_type=windows)" }), "antigravity", "antigravity UA shape (#4688)"); + assert.equal(clientFamilyOf({ "user-agent": "vendor/antigravity-wrapper/1.0" }), "other", "mid-token antigravity mention is NOT antigravity"); assert.equal(clientFamilyOf({ "x-claude-code-session-id": "s", "user-agent": "anything/1" }), "claude", "header sniff beats UA guess"); assert.equal(clientFamilyOf({ "x-opencode-session": "ses_1", "user-agent": "anything/1" }), "opencode", "opencode header sniff"); assert.equal(clientFamilyOf({ "x-bili-plugin": "dsh", "user-agent": "codex_cli_rs/1.0" }), "dsh", "declared plugin agent wins over UA shape");