Repository navigation
Fix #2474: [Bug] memos-local-plugin: config validator reports schema-declared 'reasoning' k - #2587
Open
syzsunshine219 wants to merge 2 commits into
Open
syzsunshine219 wants to merge 2 commits into
syzsunshine219 wants to merge 2 commits into
Conversation
added 2 commits
October 9, 2026 04:40
…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
…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.
syzsunshine219
marked this pull request as ready for review
November 9, 2026 15:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restores the change proposed in #2475 for review against
mainafter its former base branch,dev-v2.0.36, was deleted. The source commits and authors are preserved.Source head:
a94eb697c7a00ca8cbb307be2de153d1440183a7This PR is open for review. Review and CI against the current base are pending; validation claims in the original description below refer to the earlier snapshot. The original discussion and evidence remain in #2475.
Original change description
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,@hijzyplease review this PR.Reviewer Checklist