Repository navigation
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1649 +/- ##
==========================================
- Coverage 96.44% 96.42% -0.02%
==========================================
Files 585 585
Lines 76600 76607 +7
Branches 13175 13176 +1
==========================================
- Hits 73876 73871 -5
- Misses 1671 1676 +5
- Partials 1053 1060 +7
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
The changelog incorrectly claims exit 2 and Error: for manifest regex failures in eval check and repo run, which report ManifestError with ✗ and exit 1.
1 open issue
What changed in this PR
1 new finding.
This PR validates each contract list-pattern element independently, building on #1646’s handling of regex compilation failures.
Changes:
- Reject malformed list elements and cross-element backreferences with an element-specific error.
- Normalize regex syntax, overflow, and recursion failures to
ValueError. - Add regression tests, architecture registration, and changelog entries.
| File | Description |
|---|---|
| dokimi/tests/test_user_regex.py | Tests compilation failures and branch-filter behavior. |
| dokimi/tests/test_repo_process_metrics.py | Covers oversized and deeply nested regexes. |
| dokimi/tests/test_repo_manifest.py | Tests manifest rejection of overflowing regexes. |
| dokimi/tests/test_import_architecture.py | Registers the shared helper in the foundation layer. |
| dokimi/tests/test_context_consistency.py | Tests invalid list elements and compilation failures. |
| dokimi/dokimi/user_regex.py | Adds shared regex error normalization. |
| dokimi/dokimi/repos/process_metrics.py | Uses the shared compiler for counters. |
| dokimi/dokimi/repos/l0/branches.py | Uses the shared compiler for glob atoms. |
| dokimi/dokimi/context/contract.py | Validates list elements before joining patterns. |
| dokimi/changelog.d/20261204_130000_napetrov_list-pattern-elements.md | Documents list validation and compatibility changes. |
| dokimi/changelog.d/20261204_120000_napetrov_user-regex-refusal.md | Documents normalized regex refusals. |
Review effort: Balanced
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 4 selected item(s). CI at Review details
|
A list-valued matcher key was joined with `|`, each element wrapped in `(?:...)`, and only the joined pattern was compiled. `["a)|(?:b"]` joins to two groups and was accepted, though the element is not a regex. Each element is now compiled on its own and refused by name. A list whose elements are each a regex compiles to the same pattern as before. A list where one element refers to a group of another is refused now, since that element is not a regex alone. Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>
Thread: PRRT_kwDOVBg7g87AQkB0 Signed-off-by: Nikolay Petrov <nikolay.a.petrov@intel.com>

Summary
A list whose elements are each a regex compiles to the same pattern as before. A list in which one element refers to a
group of another (
["(a)", "\1"]) is now refused: that element is not a regex on its own, and only the joined form compiled. The same holds for a list whose elements are each invalid alone but join to a valid pattern (["(a", "b)"]).Evidence
["a)|(?:b"]accepted (joins to(?:a)|(?:b));["(a)", "\1"]accepted.After: both refused with
bad regex, naming the element.test_each_element_of_a_list_pattern_must_be_a_valid_regex_on_its_own(5 cases) fails 4 on the parentcommit (
["(", "x"]was already refused by the joined compile) and passes on this branch.make ci-local --offline --jobs static,typecheckon the head: 0 failed, 17 passed, 3 skipped. Focused tests: 126 passed.refusal is stated above and pinned by the tests. One nit, not applied:
docs/run-consistency.mdstill says a list is"one alternation" without the per-element rule.
Merge Danger
Door: two-way. No persisted format, flag or public API changes; a contract that breaks can be fixed by editing the list.
Blast Radius: narrow. Only
trace consistency --contractlist-valued matcher keys. Affected: a contract whose listelement uses a backreference to a group in another element, now refused with exit 2 instead of accepted.
Not in this PR:
["(a)", "(b)\1"]is still accepted but matches differently from its element alone (group numbers shiftwhen joined). Pre-existing on main; a fix needs renumbering, so it is left for a decision.
🤖 Generated with Claude Code