Fix fix_boolean_patterns recursion under nested combinators in if (#187)#188
Merged
Merged
Conversation
The pattern -> const rewrite only descended into `if.properties`
directly, so LinkML rules emitted as `if: { anyOf: [...] }` left
`pattern: "^true$"` against boolean fields unchanged. Pattern is
string-only, so those branches silently never matched and the
conditional `required` never fired.
Walk every subschema reachable inside the `if` clause (anyOf, oneOf,
allOf, not, and nested if/then/else) and rewrite the boolean pattern
wherever it appears. Adds tests covering direct, anyOf, oneOf, and not
nesting, plus a regression test ensuring string patterns are untouched.
Fixes #187
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
HTAN Schema Review — ✅ Approved
Automated review by htan-claude · commit
977312c6a6a890f249975230f3a6d6eaeec071aa
This is a clean, well-scoped PR — the fix is targeted, the tests cover all the new recursive paths, and all three reviewers agree there's nothing to flag.
Tip
All checklist items pass — no issues found.
Files Changed
scripts/linkml_to_flat_synapse_jsonschema.pytests/test_linkml_schema_conversion.py
Checklist Results
| Check | Result | Notes |
|---|---|---|
| Inheritance correctness | N/A | No LinkML YAML schema files changed |
| Inlining of nested objects | N/A | No LinkML YAML schema files changed |
| Slot completeness (range, title, description) | N/A | No LinkML YAML schema files changed |
| Enum integrity (alphabetical, descriptions) | N/A | No LinkML YAML schema files changed |
| Generated artifacts | PASS | Downstream JSON schema regen is correctly deferred to a follow-on PR per CLAUDE.md; 22 unit tests pass including 6 new cases covering all recursive combinator paths |
Verdict
APPROVE
Rules defined in CLAUDE.md · To update review rules, edit CLAUDE.md and open a PR to main
2 tasks
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.
Summary
scripts/linkml_to_flat_synapse_jsonschema.py::fix_boolean_patterns()only rewrotepattern: "^true$"→const: truewhen theifclause hadpropertiesdirectly. It did not descend intoif.anyOf[],if.oneOf[],if.allOf[], orif.not— so LinkML rules emitted asif: { anyOf: [...] }shipped withpattern: "^true$"against boolean fields.patternis a string-only keyword, so those branches silently never matched and the conditionalrequirednever fired (e.g.PANEL_NAMEwas not enforced whenPROTEIN_MEASURED: true).ifclause is visited (anyOf, oneOf, allOf, not, and nested if/then/else), applying the same boolean-pattern → const rewrite wherever apropertiesmap is found.if.properties,if.anyOf,if.oneOf,if.not, true/false variants, and a regression test confirming string-typed patterns are left alone.Fixes #187.
Test plan
PYTHONPATH=. python -m pytest tests/test_linkml_schema_conversion.py -v→ 22 passed (16 existing + 6 new)JSON_Schemas/v1.5.0/HTAN.SpatialLevel3-v1.5.0-schema.jsonshould now show"const": trueinside theif.anyOf[]branches forPROTEIN_MEASUREDinstead of"pattern": "^true$". Per CLAUDE.md, that regen lands in a separate downstream PR.🤖 Generated with Claude Code