enforce lossless NodeFilter (forbid extras + kind applicability)#125
Merged
Conversation
Co-authored-by: HumanBean17 <doudmitry@gmail.com>
Co-authored-by: HumanBean17 <doudmitry@gmail.com>
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.
Scope
Implements
plans/PLAN-LOSSLESS-PERMISSIVE-NODEFILTER.md§ PR-N1 - Loud-fail NodeFilter only.Files changed:
mcp_v2.pyserver.pyREADME.mdtests/test_mcp_v2.pyPlan / propose references
plans/PLAN-LOSSLESS-PERMISSIVE-NODEFILTER.mdpropose/LOSSLESS-PERMISSIVE-NODEFILTER-PROPOSE.mdWhat changed
NodeFilter.model_config = ConfigDict(extra="forbid")to reject unknown top-level filter keys.find_v2now returnsFindOutput(success=False, message=...)for filter unknown-keyValidationErrorand cross-kind populated fields before querying.search_v2now enforces symbol applicability and returnsSearchOutput(success=False, message=...)for invalid filter contract before iterating hits.neighbors_v2now wraps filter parse/model validation failures asNeighborsOutput(success=False, message=...), preserves@validate_callargument validation raises, and fails loudly on first neighbor row where populated filter fields are inapplicable to that neighbor kind.exclude_roles: []is treated as absent for applicability checks.NodeFilterfields stay in sync with_NODEFILTER_APPLICABLE_FIELDS, and documented mixed-kindneighborsfail-on-first behavior inserver.pyandREADME.md.Contract / compatibility notes
Tests run
.venv/bin/ruff check ..venv/bin/python -m pytest tests/test_mcp_v2.py -v.venv/bin/python -m pytest tests -vResults:
tests/test_mcp_v2.py: 48 passed, 3 skipped.tests: 410 passed, 10 skipped (documented skips), 2 warnings.Intentional design divergences