Repository navigation
memory.apply refuses unknown keys in nested target and action objects - #2171
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
zlareb1
left a comment
There was a problem hiding this comment.
Nested target and action blocks reject unknown keys before the handler can read or change rows. HTTP and MCP both exercise dry runs and enforcing calls. Top-level argument handling stays intact, and MCP retry examples are validated after the proposed corrections.
zlareb1
left a comment
There was a problem hiding this comment.
The Go SDK generation gate fails on this head and passes on its exact base.
|
Updated in ec3af00: sdk/go/wire/models.gen.go now carries the updated registry schema SHA-256 (no Go struct or client code changed). |
zlareb1
left a comment
There was a problem hiding this comment.
The Go SDK generator matches the committed wire models. The focused suite passed 267 tests, including HTTP and MCP rejection of unknown nested keys and validation of the corrected retry examples.
zlareb1
left a comment
There was a problem hiding this comment.
GitHub reports a merge conflict in sdk/go/wire/models.gen.go. Please reconcile with main and regenerate the Go SDK from the combined wire models.
zlareb1
left a comment
There was a problem hiding this comment.
Both transports refuse the nested unknown keys before entering the handler. The Go generator gate passed, and 234 focused tests passed. The default MCP listing exceeds its existing budget.
The nested input models of memory.apply kept Pydantic's default extra="ignore", so an unknown predicate such as target.filter.pinned or a misspelled key such as target.filter.tag_any or label.op was dropped silently and the call acted on a wider set of rows or a default mode. All seven nested input models (ApplyFilter, ApplySearch, ApplyTarget, ApplyExpire, ApplyLock, ApplyLabel, ApplyDemote) now set ConfigDict(extra="forbid"), matching KnowledgeSourceCrawlOptions and NamespaceRetrievalDefaults. MemoryApplyInput stays on default extra="ignore" so top-level transport keys, ignored_args and UNKNOWN_ARGUMENT refusals are unchanged. arg_check.known_fields accepts include_forbidden=True and arg_feedback.guesses/example walk optional and annotated nested models recursively so MCP validation errors still name unknown nested paths and suggest close field names without emitting retry examples that drop unmapped keys. Trimming repeated nested field lists from memory.apply's TOOL_DESCRIPTIONS entry keeps the default MCP listing under the 6,000 ceiling, and sdk/go/wire/models.gen.go carries the updated registry schema SHA-256. Signed-off-by: Suneeth12 <suneethreddy2005@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
The nested target and action models reject unknown keys before either transport enters the handler. The original MCP listing ceiling passed, and the Go generator reports both files current. All 234 focused tests passed.
Signed-off-by: Suneeth12 <suneethreddy2005@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
HTTP and MCP reject unknown keys in nested targets and actions before the handler runs. All 234 focused tests, including the MCP listing budget, passed. The Go generator reports both committed files current. GitHub reports a merge conflict in sdk/go/wire/models.gen.go.
… digest Signed-off-by: Suneeth12 <suneethreddy2005@gmail.com>
zlareb1
left a comment
There was a problem hiding this comment.
Both transports reject unknown nested fields before the handler runs. The corrected retry examples, the existing MCP listing budget, and the Go generator checks passed in the 279 focused tests.
zlareb1
left a comment
There was a problem hiding this comment.
The request SLI test reports the same missing _role entry on this run's clean base. The focused test passes on current main after the fixture repair in #2258. Failed job · Repair
Closes: #2155
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
memory.applyrefuses unknown keys insidetarget(filter,search,keys) and its action blocks (expire,lock,label,demote) with a422 VALIDATION_FAILEDnaming the dotted path, on both dry runs and enforcing calls, before reading or writing any rows.Why
The seven nested input models in
server/memory/api/models_apply.py(ApplyFilter,ApplySearch,ApplyTarget,ApplyExpire,ApplyLock,ApplyLabel,ApplyDemote) kept Pydantic's defaultextra="ignore". Becauseserver/transport/arg_check.pyonly inspects top-level keys, an unknown predicate such astarget.filter.pinned: false, a misspelled filter key (target.filter.tag_any), a misspelled search floor (target.search.min_similarity), or a wrong action key (label.op: "remove") was dropped beforeresolveran. The call then read and wrote a wider set of rows (or applied the default label mode) without naming the dropped key.Adding
model_config = ConfigDict(extra="forbid")to all seven nested input models mirrorsKnowledgeSourceCrawlOptionsandNamespaceRetrievalDefaults: both HTTP (422 VALIDATION_FAILED) and MCP (isError: true) now refuse the call before authorization or handler execution and report the dotted path (target.filter.pinned,label.op, etc.) on bothdry_run=trueanddry_run=false. A filter carrying only unknown keys fails withextra_forbiddenat that key's path instead of"filter needs at least one predicate".Because
arg_check.known_fieldsreturnsNoneforextra="forbid"models andarg_feedback._nested_modelpreviously checked only directBaseModelannotations one level deep, settingextra="forbid"onApplyTargetbrokearg_feedback.guessesfor nested keys.known_fieldsnow acceptsinclude_forbidden: bool = False(leaving defaultunknown_argsand top-levelignored_argsbehavior unchanged), andarg_feedback.guesses/examplewalk optional (T | None) andAnnotatednested models recursively with aseencycle guard while leavingshaped()(loom_opcatalog) unchanged.Scope and risk
server/memory/api/models_apply.py(the 7 nested input models only),server/transport/arg_check.py(known_fields(..., include_forbidden=False)),server/transport/arg_feedback.py(recursive nestedguesses/example),server/transport/mcp_descriptions.py(trim repeated nested field enumerations frommemory.apply), and focused unit tests (tests/unit/test_memory_apply.py,tests/unit/test_arg_feedback.py).MemoryApplyInputstays on defaultextra="ignore", so top-level transport/identity keys,ignored_args/X-Loom-Ignored-Argsfor unmapped top-level keys, and422 UNKNOWN_ARGUMENTfor top-level write misspellings are unchanged.tests/unit/test_arg_feedback.py::test_memory_apply_names_the_nested_key_and_shows_the_corrected_callnow asserts"target.memory_keys: Extra inputs are not permitted"instead of"target must name exactly one of keys | filter | search", because Pydantic rejects the extra key directly before_exactly_oneruns.tests/unit/test_mcp_listing_budget.pystays untouched at its6_000ceiling: trimming the repeated filter and action field lists fromserver/transport/mcp_descriptions.pypays for the seven"additionalProperties": falseentries, bringing("core", False)to5,974 <= 6,000.knowledge.query,memory.record.query,memory.bulk_set) untouched.Compatibility, rollout and rollback
memory.applynow returns422 VALIDATION_FAILED(extra_forbidden) instead of silently dropping unknown keys insidetarget,target.filter,target.search,expire,lock,label, ordemote. During a rolling upgrade where a newer release adds a predicate, an older replica running this change refuses the unknown predicate rather than sweeping without it.extra="ignore"behavior; no stored data, migrations, or generated files are affected.Tests
9d360926a:tests/unit/test_mcp_listing_budget.py,tests/unit/test_mcp_initialize_surface.py,tests/unit/test_hidden_op_says_why.py,tests/unit/test_memory_apply.py,tests/unit/test_arg_feedback.py,tests/unit/test_sdk_go_codegen.py,tests/unit/test_op_transport_contract.py,tests/unit/test_tunable_constants.py,tests/unit/test_transport_layering.py(365 passed), plustests/unit/test_public_copy.py(6 passed).target.filter.pinned,target.filter.tag_any,target.search.min_similarity,label.op) refuse withVALIDATION_FAILED(extra_forbidden), call 5 (top-levelpinned) serves withignored_args: ['pinned'], and call 6 (top-leveldryrun) refuses withUNKNOWN_ARGUMENT.ruff checkandruff format --checkon all 6 modified Python files,mypyon all 4 modified server files,scripts/gates/function_length_gate.py,scripts/gates/check_no_secrets.py, and--checkon all 14 codegen gates (sdk_go_gen,sdk_rust_gen,sdk_rust_gen --fixtures,sdk_py_gen,sdk_py_client_gen,sdk_py_admin_gen,sdk_ts_gen,agent_plugin_sync,standalone_skills,served_skills,settings_reference,settings_schema,docs_reference, andop_reach_census).make test-unitand integration tests (no local ClickHouse).AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated (an agent wrote most of the diff): Antigravity. Verified all 7 nested models,
arg_check/arg_feedbackrecursion and retry-example safety, HTTP and MCPdry_run=true/falserefusals, MCP listing budget delta, and all local tests and lint/type/codegen gates.I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make test-unitand applicable integration results are reported by CI; a full local run is not required before pushing.sdk_go_gen,sdk_rust_gen,sdk_py_gen,sdk_py_client_gen,sdk_py_admin_gen,sdk_ts_gen,docs_reference, andop_reach_census--checkall pass).tests/unit/test_public_copy.pypasses).git commit -s), as CONTRIBUTING.md asks.Note
Medium Risk
Changes validation for
memory.applynested inputs—clients that relied on silently ignored typos (e.g.tag_any,label.op) now get 422s instead of broader or default behavior—but scope is limited to that op's nested models plus arg feedback helpers.Overview
memory.applynow rejects unknown keys inside nestedtargetand action payloads instead of silently dropping them, which could widen filters or apply wrong defaults. Seven nested Pydantic models (ApplyFilter,ApplyTarget,expire/lock/label/demoteblocks, etc.) getextra="forbid", so HTTP and MCP return422 VALIDATION_FAILEDwith dotted paths (e.g.target.filter.pinned,label.op) before any handler runs.Argument feedback is updated to match:
known_fields(..., include_forbidden=True)can list legal keys on forbid-models for nested typo detection;guessesandexamplerecurse through optional/Annotatednested objects so deep misspellings get “did you mean” hints and corrected examples when safe. Thememory.applyMCP blurb is shortened to offset schema size. Tests cover nestedextra_forbidden, transport refusal before writes, and deep nested feedback behavior.Top-level
memory.applystill ignores unknown keys (ignored_args/UNKNOWN_ARGUMENTfor close top-level typos) unchanged.Reviewed by Cursor Bugbot for commit 248aa41. Bugbot is set up for automated code reviews on this repo. Configure here.