Repository navigation
fix(tidy): compare rules stored without topics - #43
Conversation
|
Thanks for the contribution! I'm considering this PR and reviewing how it fits with the other proposed changes. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: da499f74bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| reason = body.rfind(" Reason:") | ||
| if reason >= 0: | ||
| body = body[:reason] | ||
| return rulespec.parse(f"[{legacy.group(1)}] {body}" if legacy.group(1) else body) |
There was a problem hiding this comment.
Preserve tag-like parentheses in legacy rule bodies
For timestamp-prefixed rules written by collab.rule_add whose final action is, for example, Do: notify (owner of the service) without a trailing full stop, rulespec.parse calls rulespec.split and strips (owner of the service) as though it were a current-format source tag. The resulting action is just notify: an equivalent topic-format rule is missed, while a plain Do: notify rule instead receives a 1.0 duplicate score. Parse the already-extracted legacy body without applying current-format source-tag stripping.
Useful? React with 👍 / 👎.
Co-authored-by: MaxonT <173550318+MaxonT@users.noreply.github.com> Agent: codex
What does this change?
Fixes #24. Rules added in a hub without topic headings have a timestamp and author prefix, so
tidypreviously excluded them from duplicate comparison. Add a compatibility reader local totidythat recognizes those stored bullets and excludes theirReason:metadata before comparing When/Do fields. Legacy rules can now be compared with each other and with topic rules. The skipped-rule notice describes both supported formats.The change leaves the saved preferences, writing format, similarity threshold and interface-shape lint unchanged. Free-text and malformed rules remain explicitly listed as not compared.
Legacy-format boundary: this uses the same final
Reason:separator convention asrulecheck.body. The legacy format has no escaping, so a rule whose body ends with a literalReason:clause without appended metadata, or metadata that itself repeats the separator, remains ambiguous. This patch does not migrate or rewrite those stored rules.How did you check it?
The three regression cases failed against main at
c00344468fc504987c64f29d6d4c4c2a45b87fbe: all expected duplicate pairs were missing. One regression runsrule addtwice without a topic and then runs JSONtidy, also checking preferences are unchanged. Other cases cover legacy/current comparisons, optional Not and Reason, numeric-offset time zones, metadata containing field labels and malformed rules.Tested on macOS 27.2 arm64 with Python 3.14.6:
python -m pytest -q tests/test_tidy.py tests/test_rulespec.py tests/test_collab.py: 56 passed.python -m pytest -q tests: 471 passed, 3 subtests passed (88.49 seconds).python tools/privacy_scan.py --history: 213 files, 0 hits after the commit, including a freshly built wheel and sdist.git diff --check: passed.Linux, Python 3.11/3.13 and Docker installation checks have not been run locally.
AI assistance: Codex implemented the change and tests. A separate Codex reviewer found that using the first Reason separator could truncate an action containing that label. A regression reproduced the wrong duplicate pair, and the fix follows the existing final-separator convention. The reviewer independently reran all 12 tidy tests and an actual CLI counterexample and reported no remaining blocking code findings. This does not claim human review.
python3 -m pytest -q testspassespython tools/privacy_scan.pyfinds nothing