Repository navigation
fix: test fixture ergonomics vs src type surface (#1991) - #1992
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.2006-pr.1992.7701c10This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1992.tgz
npm install -g packageInstall instructions are refreshed on each push. |
[bot] 🏷 PR #1992 核查完成。逐条对照了 PR 声明、#1991 checklist、实际 diff 与本地/CI 证据,结论如下(结构化七问): 1. 是什么问题 2. 什么原因导致的 3. 怎么修复的 4. 是否有回归问题 — 无,逐项审过:
5. 是否破坏缓存 — 不涉及。未触碰任何缓存/重试/增量游标/去重键路径;session 持久化格式不变。 6. 是否改了设计方向 — 否。类型面向既有运行时语义对齐,无架构/边界/数据流转向。item 7(OpencodeAcpHooks 可选成员正确反映 host 契约)、item 10(prompt_cache_key 保持 string,kernel-owned wire 类型,bili 的非 string 防御留在 session-id.ts 边界)评估后不动,判断成立;item 9(trailing-timeout 死参数,重排=行为变更)留 owner 拍板,未动;item 4(AbsorbConfig 五字段全必填)归 acp-kernel,已在 acp-kernel 立 #502(带合规来源标记,含 prompt_cache_key facet)。 7. 是否引入了新的配置 — 不涉及。无新 env/config key/默认值。 协调提示:#1990(tests typecheck gate)仍在途且重写大部分 test 文件,rebase 时预期文本重叠、按 union-of-intents 解;已验证两种合并顺序都不破坏 master(CI 门禁不含 root-tsconfig typecheck,唯一交互是那 2 条已披露漂移,#1990 清理范围)。 判定:可合并。 方向正确(修根因不修症状)、零运行时变更有完整证据链、CI 全绿。请 owner 自行 merge:#1992 |
Closes #1991
Type-surface-only changes making the src API friendlier to test fixtures — zero runtime behavior change. Every checklist item from #1991 is handled: implemented (1, 2, 3, 5, 6, 8, 11), assessed-no-change with rationale (7, 10), owner decision pending (9), kernel-owned filed elsewhere (4).
Changes by item
Item 1 — ProxyOptions always-defaulted fields now optional (
src/config.ts,src/cli.ts)compat/streamErrorShape/passthroughSource/autoRestartOnUpdate/updateTag/advisoryCheck/releaseNotesCheckwere required in the type whileloadOptions()supplies defaults for all seven — every partial fixture had to retype the canonical block (and TS2352 comparability forcedas unknown as ProxyOptions). Now optional. The only non-defensive read wascli.tsfeeding the requiredAutoRestartHandlerConfig.enabledboolean → nowopts.autoRestartOnUpdate ?? false(default OFF = loadOptions default, behavior-preserving). All other consumers already use?./ truthy guards or acceptstring | undefined(normalizeUpdateTag).Item 2 —
zeroStats()factory (src/session.ts): exportedzeroStats(): Session["stats"];getSession()uses it. Fixtures build sessions without retyping 17 zero fields.Item 3 — missing exports:
PluginContext(dsh-native),ZodLike(opencode-native),CostRow(registry) now exported;CompressSettingsre-exported fromcompress-settings.tswhere tests already import its functions (drops theParameters<typeof f>[N]cast).Item 5 — OmpConfig/OpencodeConfig.providers optional: discovery tolerates absence (
?? {}at all 8 read sites in client-config / launcher / discover); producers always set{}.parseOmpYamlrefactored to build a local record and return{ providers }(byte-identical object graph).Item 6 — V2 registration callbacks accept synchronous returns (
opencode-v2.ts):session.hook,tool.transform,command.transformreturn unions widened to includeV2Registration. Production already consumes viaawait …?.(…)+ truthy check, so sync returns were always handled at runtime; the union simply didn't admit them, forcing async/Promise.resolve mocks in fixtures. Strictly more permissive.Item 8 — typed reads for server-stamped metadata (
src/session.ts):AnonymousPrefixAffinityStamptype +peekAnonymousPrefixAffinity(session)/peekEffectiveContextLimit(session)accessors for the shapes stamped at server.ts:2230-2235 and :2771 — no more casting theRecord<string, unknown>bag. Additive.Item 11 —
scripts/check-dist-import-annotations.d.mts: sibling declaration file so the test can statically import the checker (no dynamic-import-through-const workaround).Test sites (
tests/launcher.test.ts,tests/model-windows.test.ts,tests/launcher-max-outputs.test.ts): the 20 unguardedcfg.providers…assertion reads that item 5 newly flags — minimal?./?? {}additions, assertions unchanged.Assessed — no change (rationale)
createAcpCommandHooksalways returns both members; the correct fixture remedy is!where the factory guarantees definition (already done in Gate tests/ under CI typecheck — clear all pre-existing test type errors (#1970) #1990). Reverting to required would misrepresent the wire shape.prompt_cache_key: string): kernel-owned wire type follows the OpenAI spec. bili's non-string defense already sits exactly at the boundary (preferPromptCacheKeyIdentity, session-id.ts); loosening the wire type tounknowndegrades typing at every other site. Mentioned as a low-value facet in the acp-kernel issue below.Pending owner decision (not touched)
fn— trailing{ timeout }args are dead code today. Reordering to(name, opts, fn)would start enforcing timeouts = potential new failures under CI load = behavior change. Left alone; needs an owner call.Kernel-owned (filed elsewhere)
acp-kernel@0.0.100declares all fiveAbsorbConfigfields required while bili applies per-field kernel fallbacks (absorb.ts:52,compress-settings.ts resolveAbsorbSettings). Filed as [Gap] Core type surface stricter than actual usage: AbsorbConfig requires all five fields vs consumers applying per-field fallback (incl. prompt_cache_key wire type facet) | [Gap] 内核类型表面严于实际使用:AbsorbConfig 五字段全必填 vs 消费者逐字段 fallback(附 prompt_cache_key wire 类型 facet) acp-kernel#502 with the [Gap] 测试 fixture 人体工学 vs src 类型表面:恒默认必填字段 + 缺失类型导出迫使测试样板/cast #1991 source marker — cross-repo changes stay manual.Behavior changes
None. Every change is type-surface (optional markers, exported names, additive factories/accessors, widened unions, declaration file) plus two
?? falsedefaults in cli.ts equal to the existing loadOptions default, and assertion-level?.on parser results that are always present at runtime. No config keys, env vars, wire shapes, persistence formats, thresholds, or timing touched.Verification
npm run typecheck(tsconfig.build.json) green;npm run buildgreen including the dist annotation gate.promptCache— part of Gate tests/ under CI typecheck — clear all pre-existing test type errors (#1970) #1990's cleanup scope, untouched here).Coordination note (#1990)
#1990 (tests typecheck gate) is still open and rewrites most test files. This PR touches only three test files (assertion-level
?.guards) — expect textual overlap when one rebases onto the other; resolution is union of intents. Merging either first keeps master green: this PR introduces no new root-tsconfig errors beyond the two pre-existing message drifts above.