From 2a98b6b0b1541c33a4ee50b50869d7590c39a6ee Mon Sep 17 00:00:00 2001 From: 0xdhx Date: Mon, 3 Aug 2026 18:43:23 -0500 Subject: [PATCH] fix(#2665): keep the dot-home type guarantee #2755 chose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rebase resolution annotated both hoisted descriptors and the local in resolveKimiHooksTomlDir as ConfigHomeDescriptor. #2755 used DotHomeDescriptor there deliberately: the union permits xdg / dot-home-nested / generic-agents-root shapes, so the broader annotation drops the compile-time guarantee that this resolver selects a dot-home descriptor and nothing else. Runtime behaviour was already correct — all eleven paths resolve identically — so this restores a type-level property, not a behavioural one. Both exported constants are now pinned to DotHomeDescriptor as well, which is stricter than the ConfigHomeDescriptor they carried since round 3; the interface stays unexported and NON_REGISTRY_CONFIG_HOME_DESCRIPTORS keeps its ConfigHomeDescriptor[] type, which the narrower constants satisfy as subtypes. Found by the pre-push adversarial review of this round, which is the one claim of six it refuted. --- src/runtime-homes.cts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime-homes.cts b/src/runtime-homes.cts index 0655d68fc..0605d9055 100644 --- a/src/runtime-homes.cts +++ b/src/runtime-homes.cts @@ -491,7 +491,7 @@ export function resolveKimiGlobalDir(opts: ResolveKimiOpts = {}): string { * homes: KIMI_CONFIG_DIR (registry-visible, already covered) and KIMI_SHARE_DIR * (this one), so a derivation keyed only on the registry looks complete and is not. */ -export const KIMI_HOOKS_TOML_DESCRIPTOR: ConfigHomeDescriptor = { +export const KIMI_HOOKS_TOML_DESCRIPTOR: DotHomeDescriptor = { kind: 'dot-home', name: '.kimi', env: ['KIMI_SHARE_DIR'], @@ -509,7 +509,7 @@ export const KIMI_HOOKS_TOML_DESCRIPTOR: ConfigHomeDescriptor = { * commit, which is the property NON_REGISTRY_CONFIG_HOME_DESCRIPTORS exists to * guarantee. Each product's env var stays scoped to that product (#2755). */ -export const KIMI_CODE_HOOKS_TOML_DESCRIPTOR: ConfigHomeDescriptor = { +export const KIMI_CODE_HOOKS_TOML_DESCRIPTOR: DotHomeDescriptor = { kind: 'dot-home', name: '.kimi-code', env: ['KIMI_CODE_HOME'], @@ -586,7 +586,7 @@ export function resolveKimiHooksTomlDir(opts: ResolveKimiHooksTomlOpts = {}): st // Explicit comparison rather than an object lookup keyed on `runtime`: the // value originates from argv, and an index would resolve inherited keys // (`constructor`, `__proto__`) to something that is not a descriptor. - const descriptor: ConfigHomeDescriptor = opts.runtime === 'kimi-code' + const descriptor: DotHomeDescriptor = opts.runtime === 'kimi-code' ? KIMI_CODE_HOOKS_TOML_DESCRIPTOR : KIMI_HOOKS_TOML_DESCRIPTOR; return resolveConfigHomeFromDescriptor(descriptor, { env, home });