Skip to content

test: record Copilot Gemini schema constraints - #1415

Merged
ranxianglei merged 2 commits into
ranxianglei:masterfrom
InCerryGit:2026-09-26_copilot-schema-contract
Sep 26, 2026
Merged

ranxianglei merged 2 commits into
ranxianglei:masterfrom
InCerryGit:2026-09-26_copilot-schema-contract

Conversation

@InCerryGit

Copy link
Copy Markdown
Contributor

Record the Copilot Gemini compress-schema rejection in the wire-contract ledger and fake upstream validator. Synthetic regression tests independently reject array-valued types and untyped alternatives, accept explicit typed alternatives, and preserve validation for other model families.

This is the Bili regression half of the fix. The schema producer is acp-kernel; its source correction must be released before a follow-up updates Bili's exact dependency pin. This PR alone does not change the installed kernel or fix production requests.

Validation: Bili typecheck, targeted Copilot and wire-contract tests, and build pass. No production configuration, prompts, or diagnostic logs are included.

Tracks #1414 (kept open until the fixed kernel is released and consumed). Kernel issue: ranxianglei/acp-kernel#447.

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review: mergeable. Test-only, additive, green everywhere. Details below.

① Direction (original issue)

Correct half of a two-part fix, correctly scoped. #1414 explicitly assigns to Bili "a wire-contract regression to record this provider constraint"; the schema producer lives in acp-kernel (src/compress-tools.ts, tracked as acp-kernel#447) and must be released before any pin bump — this PR deliberately does NOT touch the pin, which is right (bumping to a not-yet-published kernel would fail CI at npm ci). Ledger entry + validator clause + regression tests land inside the fixing PR, per the wire-constraint-ledger rule.

② Regression inventory (existing behaviors touched)

  • WIRE_RULES: sole consumer is the ledger self-check (tests/wire-contract.test.ts:111); the new rule ships with its probe fixture, and prepending WC-008 breaks nothing order-dependent (none exists).
  • validateOpenAiChatBody / VALIDATORS["openai-chat"]: sole consumers are the fake upstreams and ledger probes. The change is strictly additive — WC-008 clauses fire only when typeof body.model === "string" && body.model.startsWith("gemini-"). Grepped the whole repo: no existing body reaching this validator carries a gemini-* model (the only gemini-named models in tests ride the google-native wire through validateGoogleBody; Layers A/B/C synthetic bodies carry no model field; Layer D's openai lane uses gpt-test). Zero drift in existing validation paths.
  • Goldens snapshot tool schemas, not WIRE_RULES — untouched, and the golden suite passes.
  • No src/ changes, no config/persistence/wire/version/lockfile changes. Production behavior unchanged, as claimed.

③ Code

The encoding matches the real producer bug exactly. Inspected the pinned kernel 0.0.93 COMPRESS_TOOL_OPENAI: content.type: ["array","string"] plus two required-only alternatives ({required:["startId","endId","summary"]} / {required:["startRef","endRef","summary"]}). Running validateGeminiSchema over that actual schema yields precisely 3 violations (1× scalar-type, 2× untyped-alternative) — the two failure modes from the repro, no more, no less. Recursion is sound (non-object branches flagged once then skipped; terminates on plain-object trees). Scoping the gate to gemini-* model names matches Copilot Gemini's naming and leaves every other family's validation intact.

④ Test teeth

  • Rejects both bad shapes independently (gate removal or clause loosening fails it).
  • Accepts the explicit typed-alternative form (guards over-tightening) AND asserts other-model still gets [] (guards scope creep into other families' validation).
  • Ledger self-check fixture keeps WC-008 permanently "live-enforced".
  • Pure functions, no ports/env — deterministic.

⑤ Diff & verification

3 files, +51/-0, every line on-purpose; no whitespace/lockfile/unrelated churn. Local: targeted copilot-schema-contract + wire-contract + wire-contract-golden = 18/18 pass, npm run typecheck clean. CI on head 8df2ca64: 12/12 checks success (incl. full test matrix + e2e lanes).

One forward-looking note (non-blocking, for the follow-up pin-bump PR): Layers A/B synthetic bodies carry no model field, so after the fixed kernel ships and Bili bumps the pin, nothing will automatically prove the pinned kernel's COMPRESS_TOOL_OPENAI passes WC-008 under a gemini-* model. Suggest the pin-bump PR adds that assertion (real kernel export through validateOpenAiChatBody with a gemini-* model). It can't land here — the currently pinned kernel violates WC-008 by design (that's the unfixed producer-side bug), so it would go red today.

中文摘要:审核了「记录 Copilot Gemini schema 约束」的纯测试 PR(账本 WC-008 + 假上游校验 + 回归测试),方向与 #1414 分工一致、对既有校验零行为漂移、编码与当前内核 0.0.93 的真实缺陷逐条吻合,本地 18/18 + typecheck + CI 12/12 全绿,可以合并。

@ranxianglei

Copy link
Copy Markdown
Owner

#1417 批次深审 + 修复交付

判定:✅ 可合(修后)

干什么/动机:wire-contract 账本新增 WC-008——GitHub Copilot 的 Gemini 端点要求 schema type 为单标量字符串(拒绝 type 数组)且 anyOf 分支必须自带 type(required-only 对象分支 400)。来源:opencode V2 → bili → Copilot Gemini 的实测 400(invalid_request_body)。纯测试,零运行时。

四轴:压缩行为/推荐列表/cache 命中/压缩质量全部零触碰。

审查发现与修复(新 head 683e0d3)

  1. WC-008 被插在数组头部 → 移到尾部(账本只增不改的纪律:新规则接续编号追加)
  2. provenance 只写 "synthetic reproduction" 无持久锚 → 补 durable 引用(本 issue + Gemini REST Schema 文档),并明示内核 openai-chat compress schema 现状违反此规则且尚无 lane 强制(防止读者误以为已生效)
  3. 定向门禁 11/11 ✅ + typecheck ✅

非阻塞观察

  • WC-008 目前是"知识记录",等内核 schema 改造(去 type 数组)落地时才加 lane 强制——账本先行正是 ledger 的意义(约束先于事故入账)
  • golden 重新生成为 no-op,无漂移

CI 绿后即可合(纯测试,不在 auto-merge 禁区)。

@ranxianglei

Copy link
Copy Markdown
Owner

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Fixed-head verified — correct and green locally — but PR #1415's head ref does not contain the fix; do not merge as-is.

What I verified (lineage 683e0d35, branch ranxianglei:2026-09-26_copilot-schema-contract)

  • Fix-commit diff reviewed against the PR head — exactly the two claimed changes, nothing else:
    1. WC-008 moved from the HEAD of WIRE_RULES to the tail (after the WC-007/bili#1403 entry) — ledger append-in-order discipline restored;
    2. provenance made durable: bili test: record Copilot Gemini schema constraints #1415 synthetic repro + Gemini REST Schema docs reference, plus the explicit note that the pinned kernel's openai-chat compress schema currently violates this rule and no lane enforces it yet (prevents readers assuming it's live).
  • No content drift in the rebase: 26718c3d ("test: record Copilot Gemini schema constraints") is patch-identical to the original 8df2ca64 (same patch-id 4bde85b1…) — copilot-schema-contract.test.ts, wire-contract.test.ts and the WC-008 validator logic are byte-equivalent.
  • Local gates on the fixed head: targeted suite (copilot-schema-contract + wire-contract + wire-contract-golden) 18/18 pass, npm run typecheck clean — consistent with your 11/11 + typecheck ✅.
  • Base freshness: the branch sits directly on the current master tip (c030b566, docs: issue templates — structured bug form + explicit blank template #1300 merge) — no stale-base risk.

⚠️ Blocker before merge — the PR object points at the pre-fix commit

  • PR test: record Copilot Gemini schema constraints #1415's head ref is still InCerryGit:2026-09-26_copilot-schema-contract @ 8df2ca64 (pre-fix). Merging it now would land the WC-008-at-ledger-head variant your review rejected.
  • The fixed commits exist only on the main-repo branch ranxianglei:2026-09-26_copilot-schema-contract @ 683e0d35 — they were never pushed to the fork branch the PR tracks.
  • Consequence: CI has never run on 683e0d35 (zero check-runs — plain-branch pushes don't trigger the workflows), so "CI 绿" doesn't exist yet for the fixed head either.

Suggested path (your call)

  1. Close test: record Copilot Gemini schema constraints #1415 and reopen from ranxianglei:2026-09-26_copilot-schema-contract → master (GitHub cannot retarget an existing PR's head ref), or
  2. Force-push the two commits to your fork branch — non-fast-forward, since 26718c3d is a rebase of 8df2ca64.

Either way CI will then run on the fixed head, and per your verdict it's immediately mergeable (pure test, outside auto-merge禁区). Say the word and I'll open the replacement PR from the main-repo branch.

Sequencing note

#1423 (acp-kernel 0.0.95 pin) is already open. When it gets reviewed, the producer-fidelity assertion from my first-pass review — assert the pinned kernel's real COMPRESS_TOOL_OPENAI passes validateOpenAiChatBody under a gemini-* model — belongs there; that's the point at which WC-008 stops being documentation-only and gains real teeth.


修复内容已核实无误(WC-008 移至账本尾部 + 持久化 provenance,本地定向 18/18 与 typecheck 全绿),但 PR 的 head ref 仍指向修复前的旧提交 8df2ca6,修复仅存在于主仓分支 683e0d3 且未跑过任何 CI——请先关闭重开(或强推 fork 分支)使 PR 指向修复后的 head,再合并。

@ranxianglei
ranxianglei merged commit 70a14f1 into ranxianglei:master Sep 26, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants