fix(core): parse picoschema modifier descriptions#796
Conversation
|
Claude finished @groksrc's task in 1m 18s —— View job PR Review: Fix picoschema modifier descriptionsTasks:
SummaryThis is a well-targeted bug fix. The root cause was correctly identified: Code Quality Checklist
ObservationsThe core change is correct and clean. The regex: MODIFIER_RE = re.compile(r"\(\s*(array|enum|object)\s*(?:,\s*([^)]*?))?\s*\)\s*$")correctly captures the modifier type (group 1) and optional description (group 2). The Description precedence is consistent. For all three field types (enum, object, scalar), the key-modifier description takes priority over the value-side description. This is a sane policy and applied consistently:
Backward-compat wrapper is a good pattern. Keeping Minor Issues1. Docstring examples in In "name" -> ("name", True, False, False)
"role?" -> ("role", False, False, False)
"tags?(array)" -> ("tags", False, True, False)But the function returns 2. New
ResultThis PR is ready to merge. The fix is correct, the tests are thorough, and the code is clean. The minor docstring inconsistency is the only thing worth noting, and it can be fixed in this PR or as a follow-up. |
7ac0ea9 to
868f557
Compare
|
Claude finished @groksrc's task in 2m 15s —— View job PR Review: fix(core): parse picoschema modifier descriptionsTasks:
SummaryCorrect, well-scoped bug fix. The root cause was properly identified and the replacement implementation is clean. The previous review's minor docstring issue (4-element tuple examples) has already been fixed in the current code — Code Quality Checklist
CodeQL Security Concern — ResolvedThe CodeQL alert references The one pre-existing regex in Observations
One minor robustness note: The function uses Description precedence is consistent and intentional. Key-modifier description takes priority over value-side description for all field types. The
ResultReady to merge. The fix is correct, the CodeQL concern from the earlier PR version is resolved by the non-regex implementation, tests are thorough, and the code follows project conventions. The |
868f557 to
43a5dc6
Compare
|
Claude finished @groksrc's task in 1m 55s —— View job PR Review: fix(core): parse picoschema modifier descriptionsTasks:
SummaryTargeted, correct bug fix. The root cause was clear: Code Quality Checklist
Key Design Decisions Verified
A previous review draft raised a concern about
The test at No regex = no CodeQL concern. The CodeQL alert referenced Description precedence is consistent. Key-modifier description takes priority over value-side description for all field types:
ResultReady to merge. The fix is correct, the tests are thorough, all checklist items pass. No issues found. |
43a5dc6 to
f7238f9
Compare
|
Claude finished @groksrc's task in 1m 0s —— View job PR Review: fix(core): parse picoschema modifier descriptionsTasks:
SummaryCorrect, well-scoped bug fix. The root cause ( Code Quality Checklist
Key Design Decisions Verified
Traced through the edge case
This is validated by Empty description handled cleanly. CodeQL alert is resolved. The alert referenced Description precedence is consistent across all field types:
Backward-compat wrapper is sound. ResultReady to merge. The fix is correct, the tests are thorough, all checklist items pass, and the CodeQL concern from the earlier version is fully resolved. No issues found. |
Signed-off-by: Drew Cain <groksrc@gmail.com>
f7238f9 to
2de95d1
Compare
|
Claude finished @groksrc's task in 1m 32s —— View job PR Review: fix(core): parse picoschema modifier descriptionsTasks:
SummaryCorrect, well-scoped bug fix. Code Quality Checklist
Key Design Decisions Verified
Non-modifier parens handled correctly. If a key has a paren suffix but the inner token isn't in CodeQL alert is resolved. The alert referenced Description precedence is consistent across all field types:
Note on
|
💡 Codex ReviewWhen a schema field name itself contains parentheses and also uses a modifier, such as ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude finished @phernandez's task in 2m 50s —— View job PR Review: fix(core): parse picoschema modifier descriptionsTasks:
SummaryTwo-commit fix: the first parses modifier descriptions in picoschema field keys; the second (added in response to the Codex review) correctly handles field names that themselves contain parentheses, like Code Quality Checklist
Key Design Decisions VerifiedCodex concern resolved by commit 2350845The Codex review identified that The second commit replaces depth = 0
for index in range(len(stripped_key) - 1, -1, -1):
char = stripped_key[index]
if char == ")":
depth += 1
elif char == "(":
depth -= 1
if depth == 0:
open_paren_index = index
breakThis finds the outermost
All three cases are now explicitly tested in Implementation is purely O(n) — CodeQL concern closedThe only regex remaining is Description precedence is consistent
|
Summary
Closes #794.
Implements parsing for picoschema modifier descriptions in schema field keys, so valid syntax like
status(enum, current state): [active, inactive]andtags(array, list of tags): stringno longer treats the entire key as the field name.Root Cause
_parse_field_keyonly recognized exact suffixes like(enum),(array), and(object). When the modifier included a picoschema description, such as(enum, current state), the parser left the suffix in the field name. Validation then looked for observations like[status(enum, current state)]instead of[status].Changes
(array|enum|object, description)suffixes without using a regex on user-controlled schema keys._parse_field_key_partstests for the description-return contract, including descriptions containing parentheses.schema_validateregression test matching the issue shape.search_type="text", so Windows unit CI does not depend on loading the semantic embedding model for pagination/filter assertions.Validation
main:status(enum, current state)andtags(array, list of tags)were literal field names and realstatus/tagsobservations were unmatched.just typecheck-> passed.BASIC_MEMORY_ENV=test uv run pytest -p pytest_mock -v --no-cov tests/mcp/test_tool_search.py-> 48 passed.uv run pytest tests/schema tests/mcp/test_tool_schema.py-> 148 passed.uv run ruff check tests/mcp/test_tool_search.py tests/mcp/test_tool_schema.py src/basic_memory/schema/parser.py tests/schema/test_parser.py-> passed.