Repository navigation
Fix #2474: [Bug] memos-local-plugin: config validator reports schema-declared 'reasoning' k - #2475
Memtensor-AI wants to merge 2 commits into
Conversation
…2474) `pruneUnknown` used DEFAULT_CONFIG as the "known keys" oracle, so every schema-declared `Type.Optional(...)` field without a default value was flagged on every boot: config.warning message="unknown config key 'llm.reasoning' (…)" config.warning message="unknown config key 'skillEvolver.reasoning' (…)" config.warning message="unknown config key 'l3Llm.reasoning' (…)" `reasoning` is declared in LlmSchema / SkillEvolverSchema and the value was applied end-to-end — only the warning was wrong. MemTensor#2248 patched the same class of defect for `llm.maxTokens` / `llm.headers` by seeding defaults, but every future optional field would reintroduce the bug. Walk the TypeBox schema instead: use the `properties` map of `type: "object"` nodes to decide what is known, and treat `patternProperties` (TypeBox `Type.Record`) as a free-form map so `llm.headers` / `logging.channels` continue to accept arbitrary child keys. `FREE_FORM_CONFIG_PATHS` stays as an explicit allowlist for backward compatibility. The `unknown config key …` warning text, the pass-through semantics, and the downstream pipeline (deepMerge/Value.Default/Value.Errors) are all preserved. Tests: full plugin unit suite 1599 pass + 1 skipped (0 fail), the new `schema-driven-unknown-keys.test.ts` adds 9 cases covering reasoning (no warning), typos (still warn), free-form Record maps, and nested unknowns inside a known Optional block. Integration suite 6/6 green. `tsc -p tsconfig.json --noEmit` clean. Fixes MemTensor#2474
🤖 Open Code ReviewTarget: PR #2475 🔍 OpenCodeReview found 1 issue(s) in this PR. 1.
|
🔧 Open Code Review requested Agent fixOpen Code Review found 2 issue(s). I have resumed the development Agent to fix them.
The Agent will push a new commit to this PR branch. OCR will recheck after the commit is pushed. |
…Guard Addresses the two OCR findings on MemTensor#2475: 1. `pruneUnknown` used to silently fall through when `known` was null — e.g. if a future schema refactor introduced a `Type.Union`, `Type.Intersect`, or `Type.Any` at a recursed-into node, every child key would be passed through verbatim with no warning. The guard `if (known && !(k in known))` short-circuited on falsy `known` and nothing emitted a diagnostic. Now the `known === null && !freeFormHere` case takes an early return with an explicit warning so the bypass is visible rather than silent. `Type.Record` nodes still skip the check via `freeFormHere`, so the current schema's behaviour is unchanged. 2. The three helpers `schemaObjectProperties`, `schemaAcceptsAnyKey`, `isObjectSchema` all repeated the same `(node as { type?: unknown }).type === "object"` inline cast. Replaced with TypeBox's own `KindGuard.IsObject` / `KindGuard.IsRecord` so the introspection stays aligned with TypeBox's internal representation. Tests: tests/unit/config/ (109 tests) still pass; `npm run lint` is clean.
❌ Automated Test Results: FAILED
Error detailsBranch: |
Description
Fixes #2474 — the
memos-local-pluginconfig validator falsely reported schema-declaredreasoningfields (llm.reasoning,skillEvolver.reasoning,l3Llm.reasoning) as unknown config keys on every boot. The root cause waspruneUnknowninapps/memos-local-plugin/core/config/index.tsusingDEFAULT_CONFIGas the "known keys" oracle, which misses anyType.Optional(...)field without a concrete default — the same defect class as #2247/#2248.The fix rewrites
pruneUnknownto walk the TypeBoxConfigSchemadirectly: it uses thepropertiesmap oftype: "object"nodes to decide what is known, and treatspatternProperties(TypeBoxType.Record) as a free-form map sollm.headers,logging.channels, and similar free-form sections continue to accept arbitrary child keys. The existingFREE_FORM_CONFIG_PATHSallowlist is preserved for backward compatibility. The warning text, pass-through semantics, and the downstream pipeline (deepMerge → Value.Default → Value.Errors) are all unchanged.Verification: a new
tests/unit/config/schema-driven-unknown-keys.test.tsadds 9 regression cases (reasoning no-warning across all three LLM slots, typos still warn, Record-based free-form maps unchanged, nested unknowns inside a known Optional block still warn, resolved config retains the reasoning block byte-for-byte). Full plugin unit suite 1599 pass + 1 skipped, integration suite 6/6,tsc -p tsconfig.json --noEmitclean.Related Issue (Required): Fixes #2474
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Automated tests are pending.
Checklist
@whipser030, @hijzy please review this PR.
Reviewer Checklist