Consolidates the #1301 served-surface gate and the #1302 kernel-export gate
into one wire-contract suite and extends it per owner decision on #1304
(items 1+2+3, plus the 4-protocol scripted-client matrix phase):
- tests/wire-contract-fakes.ts: WIRE_RULES ledger (WC-001..WC-006, each with
production/doc provenance) + strictest-known validation for all four wires
(anthropic /v1/messages, openai chat, responses, google v1beta) + four
validation-parity fake upstreams on listen(0) with canned per-wire replies.
- tests/wire-contract.test.ts: four layers — ledger self-check (every rule id
has a live enforcement clause), A kernel exports, B bili-built surfaces,
C plugin manifest (default + opt-in), D live proxy-mode forward of one
client-shaped turn per protocol through the matching fake (asserts the
forwarded tool set is exactly bili's intended surface and the fake's
strictest validation accepts it). The anthropic lane reproduces #1299
end-to-end. Supersedes tests/kernel-pin-wire-schema.test.ts and
tests/issue1299-anthropic-top-level.test.ts (all their assertions kept).
- tests/wire-contract-golden.test.ts + tests/golden/wire-contract/*.json:
byte-equal golden snapshots of every advertised tool schema at both layers
(kernel exports, bili surfaces, plugin manifest default+opt-in); manifest
version normalized to <VERSION> so release commits don't churn it.
- scripts/update-wire-contract-goldens.ts: explicit regeneration path.
- AGENTS.md §7.3: institutional rule — every upstream rejection/validation
constraint becomes a permanent wire-contract rule inside the fixing PR;
the ledger only grows.
Node resolves entry-point symlinks, so when the gate script is invoked through a symlink (pnpm-style symlinked trees, /tmp -> /private/tmp), process.argv[1] no longer string-matches import.meta.url and the main-module guard silently skipped the whole check (exit 0, no output) — a silent gate death of exactly the class this gate exists to prevent. Compare realpathSync(fileURLToPath(import.meta.url)) against realpathSync(argv[1]) instead. Verified: direct/symlink/copy invocations all run the check; negative case still fails loudly; unit tests pass.
Non-minified esbuild output keeps class-member JSDoc comments; undici's
{import('./client.js')}-style type annotations therefore survive into every
dist entry. Node's ESM loader ignores them, but opencode's plugin loader
resolves them as real files -> ENOENT -> 'failed to load plugin' -> silent
dead lane for all modern versions under opencode 1.x.
Set minifyWhitespace via tsup's esbuildOptions hook (drops non-legal
comments, keeps structure + license footers) and add a build gate that
fails if relative import()/require() text ever reappears in dist.
Headless, key-free verification for the real-machine gap in #686:
confirm that codex accepts the <CODEX_HOME>-bili overlay produced by
`bili codex` and registers the bili MCP server, on a hosted Windows
runner. Uses `codex mcp list` (reads config.toml only, never calls a
model) so no E2E_UPSTREAM_* secrets are needed.
Refs #686