Relax parsing requirements to allow hyphens and periods#139
Merged
ColtonPayne merged 7 commits intomainfrom Apr 22, 2026
Merged
Relax parsing requirements to allow hyphens and periods#139ColtonPayne merged 7 commits intomainfrom
ColtonPayne merged 7 commits intomainfrom
Conversation
jaikrishnap98
approved these changes
Apr 18, 2026
Member
jaikrishnap98
left a comment
There was a problem hiding this comment.
Looks good to me. I ran the tests and aslo verified the changes
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
Relaxes identifier/entity validation across the fact and rule parsers, splits the rule parser's single identifier regex into separate predicate/component regexes, and aligns fact and rule component rules so any entity valid as a fact can also appear as a grounded atom in a rule.
Final regex layout
./-@[a-zA-Z_][a-zA-Z0-9_.\-]*[a-zA-Z0-9_][a-zA-Z0-9_.@\-]*[a-zA-Z_][a-zA-Z0-9_.\-]*[a-zA-Z0-9_][a-zA-Z0-9_.@\-]*Fact and rule components share the same regex. Predicates are stricter than components (no leading digit, no
@).Changes
pyreason/scripts/utils/fact_parser.py_PREDICATE_REand_COMPONENT_RE._validate_predicate()and_validate_component()helpers.(,),:bans on components — covered by the regex.pyreason/scripts/utils/rule_parser.py_IDENTIFIER_REinto_PREDICATE_RE(identifiers) and_COMPONENT_RE(entities — matchesfact_parser._COMPONENT_RE)._validate_component_namenow uses_COMPONENT_RE; removed the now-unreachable digit-start error branch.tests/unit/dont_disable_jit/test_rule_parser.py-(now valid) to!(still invalid) in three tests.test_head_variable_starts_with_digit— digit-leading rule components are now valid by design.tests/api_tests/test_pyreason_reasoning.pyperson("A")toperson(A)— quoted entity names are no longer valid under the stricter component allowlist.Test plan
@parse:has-vuln(node-1),cve.2024.1234(host.a, host.b),person(123),user(alice@example.com)p(1X) <- b(1X),p(a@b) <- q(a@b)!,", leading@,~,/) are still rejectedNote
The branch name and first commit mention "spaces" but spaces are not allowed — only
-,., and@were added across the changes.